Hi all,
I'm new to ruby on rails. i've been following the Simply Rails 2 Book and got me going to creating my own application. I am having trouble trying to get a simple edit/update going. Everytime I hit submit, I get the following error:
I have a form: edit.html.erbCode: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"}}
Here is my controller:Code:<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 %>
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.





Bookmarks