I'm doing the tutorial for RoR and am getting an exception:
SyntaxError in ArticlesController#index
"....rails/blog/app/views/articles/index.html.erb:18: syntax error, unexpected keyword_ensure, expecting end-of-input ensure ^"
It points to line 18 of an 16 line file. index.html.erb:
<h1>Listing articles</h1>
<table>
<tr>
<th>Title</th>
<th>Text</th>
</tr>
<% @articles.each.do |article| %>
<tr>
<td><%= article.title %></td>
<td><%= article.text %></td>
<td><%= link_to 'Show', article_path(article) %></td>
</tr>
<% end %>
</table>
The articles_controller.rb file:
class ArticlesController < ApplicationController
def index
@articles = Article.all
end
def show
@article = Article.find(params[:id])
end
def new
end
def create
@article = Article.new(article_params)
@article.save
redirect_to @article
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
Not sure where my error is. I'm using LightTable to edit the work.
@articles.each.do |article|
should probably be@articles.each do |article|
– Brad Werth