Hello all. I'm new to RoR. I am having trouble trying to get a simple
edit/update going. Everytime I hit submit, I get the following error:
+++++++++++++++++++++
Couldn't find Content without an ID
Request
Parameters:
{"format"=>"#<content:0x4d3daac>",
"commit"=>"Update",
"_method"=>"put",
"authenticity_token"=>"axBSuIWVTMRB2CKcmMO59tqtOlMtXRSXQQ7xeHEMd78=",
"content"=>{"title"=>"About Us",
"verbiage"=>"The company was formed in 2008 by seven healthcare
professionals involved in the areas of acute care hospital,
rehab hospital,
skilled nursing and rehab,
out-patient clinics,
and Home Health Care. Update"}}
+++++++++++++++++++++++++++++
I have a form called edit.html.erb:
<h2>Edit content</h2>
<% form_for @content do |f| %>
<p>
<%= f.label :title %><br/>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :verbiage %><br/>
<%= f.text_area :verbiage %><br/>
</p>
<%= f.submit "Update"%>
<% end %>
+++++++++++++++++++++++++++++++++++++
Here's my controller code:
class ContentsController < ApplicationController
layout 'subpages'
def new
@content = Content.new
end
def create
@content = Content.new(params[:content])
@content.save
end
def edit
@content = Content.find(params[:id])
end
def update
@content = Content.find(params[:id])
@content.update_attributes(params[:content])
redirect_to :action => "edit", :id => @content.id
end
end
++++++++++++++++++++++++++++++++++++
i've been trying to figure this out for 3 days but no luck. The
solutions on the web and books seem to explain that I need to have id
passed to the controller, but I thought form_for @content should
already take care of that. I would appreciate all the help i can get.
Thanks.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.