I am trying to set "edit" function for a simple CMS. I can make it to create/delete, but it just won't let me "edit".
here is the error message: SyntaxError in SectionsController#edit app/views/sections/edit.html.erb:42: syntax error, unexpected keyword_ensure, expecting keyword_end Extracted source (around line #42): 40 41
when I checked my edit.html.erb. it seems fine? 'index'}, :class => 'back-link') %><div class="sections edit">
<h2>Update Sections</h2>
<%= form_for(:two, :url => {:action => 'update', :id => @one.id}) do |f| %>
<table summary="Section form fields">
<% @one.each do |f| %>
<tr>
<th>Name</th>
<td><%= f.text_field(:name) %></td>
</tr>
<tr>
<th>Position</th>
<td><%= f.text_field(:position) %></td>
</tr>
<tr>
<th>Visible</th>
<td><%= f.text_field(:visible) %></td>
</tr>
<tr>
<th>content_type</th>
<td><%= f.text_field(:content_type) %></td>
</tr>
<tr>
<th>content</th>
<td><%= f.text_field(:content) %></td>
</tr>
<tr>
<th>page_id</th>
<td><%= f.text_field(:page_id) %></td>
</tr>
</table>
<div class="form-buttons">
<%= submit_tag("Update Section") %>
</div>
<% end %>
</div>
Here is the controller:
class SectionsController < ApplicationController
def index
@one = Section.all
end
def show
@one = Section.find(params[:id])
end
def new
@one = Section.new
end
def create
@one = Section.new(section_params)
if @one.save
flash[:notice] = "Section created successfully!"
redirect_to(:action => 'index')
else
render('new')
end
end
def edit
@one = Section.find(params[:id])
end
def update
@one = Section.find(params[:id])
if @one.update_attributes(section_params)
flash[:notice] = "Subject updated successfully!"
redirect_to(:action => 'show', :id =>@one.id)
else
render('edit')
end
end
def delete
@one = Section.find(params[:id])
end
def destroy
subject = Section.find(params[:id]).destroy
flash[:notice] = "Subject deleted successfully!"
redirect_to(:action => 'index')
end
private
def section_params
params.require(:two).permit(:id,:name,:position,:visible,:page_id,:content,:content_type)
end
end
Thanks so much!!
<% end %>in yourform- Pavandoblock? you need an<% end %>for that too - Pavan