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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If you did not use a generator to make your scaffolding, then you may not have your routes set up correctly. new might be calling edit so there is not parameter. On Tue, Feb 23, 2010 at 6:47 AM, Butterson <jax502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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]) > -SxirU7qN7fhLYScDn9snng@public.gmane.org > end > > def edit > @content = Content.find(params[:id]) > end > > def update > @content = Content.find(params[:id]) > -SxirU7qN7fhz+rKdNCS7uQ@public.gmane.org_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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Curtis Cooley curtis.cooley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org home:http://curtiscooley.com blog:http://ponderingobjectorienteddesign.blogspot.com ==============Leadership is a potent combination of strategy and character. But if you must be without one, be without the strategy. -- H. Norman Schwarzkopf -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 February 2010 14:47, Butterson <jax502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > 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. >The one bit of information you''ve missed out there is the url your form has posted to. It should be something like: http://your.site/contents/update/12345 The number at the end of the URL is the id of the "content" record you are trying to update. If it''s missing something''s wrong somewhere. If you view source of the html page before you post the form, where does the form say it''s going to post to? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 23, 8:47 am, Butterson <jax...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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"}} > > +++++++++++++++++++++++++++++Yup, there''s no id param there, and the format value is messed up for some reason. Even though your code looks fine to me at first glance. What does your routes.rb file look like? Jeff -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 February 2010 16:09, Jeff <cohen.jeff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What does your routes.rb file look like?+1 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for your replies. I didn''t use / or generate scaffolding for this project. Here is what my routes.rb looks like: ActionController::Routing::Routes.draw do |map| map.resource :content map.resource :weblink map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' end After doing a view-source on my form before submission, here''s what I found: <form action="/content.%23%3Ccontent:0x373ac10%3E" class="edit_content" id="edit_content_2" method="post"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="2KH+rzW8Xy68gwDdjceXEqJH2aM69PdV44Hx0UVbooA=" /> On Feb 23, 12:01 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 February 2010 16:09, Jeff <cohen.j...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > What does your routes.rb file look like? > > +1-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 February 2010 19:40, Butterson <jax502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> map.resourceS :content > map.resourceS :weblink:-) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Uggh! I can''t believe it''s that missing ''s'' that was causing me heartache. I also changed ''content'' to ''contents'' and it''s working fine after the update. I guess I need to read more about this routes.rb file. I still don''t have a 100% grasp on it. Thanks all for your help. On Feb 23, 2:58 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 February 2010 19:40, Butterson <jax...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > map.resourceS :content > > map.resourceS :weblink > > :-)-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 February 2010 20:16, Butterson <jax502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Uggh! I can''t believe it''s that missing ''s'' that was causing me > heartache. I also changed ''content'' to ''contents'' and it''s working > fine after the update. I guess I need to read more about this > routes.rb file. I still don''t have a 100% grasp on it. Thanks all for > your help. >Pleasure. http://api.rubyonrails.org/classes/ActionController/Routing.html Also, you don''t need to wait three days before asking for help. If a couple of hours of Googling doesn''t solve it, you''re probably about ready for new eyes on your problem :-) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks. Well, I work on my project a few hours a day after work so it''s not exactly 3 straight days. But you''re right, sometimes Googling just isn''t enough. I''m glad to have found this group. I''m pretty sure I''ll have a few more questions later. Any other books you can recommend for Ruby on Rails? I''m starting to love this new framework after just a few days of experimenting and would like to continue going deeper. I currently have Simply Rails 2 by Patrick Lenz and Learning Rails by St. Laurent & Dumbill. On Feb 23, 3:46 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 February 2010 20:16, Butterson <jax...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Uggh! I can''t believe it''s that missing ''s'' that was causing me > > heartache. I also changed ''content'' to ''contents'' and it''s working > > fine after the update. I guess I need to read more about this > > routes.rb file. I still don''t have a 100% grasp on it. Thanks all for > > your help. > > Pleasure. > > http://api.rubyonrails.org/classes/ActionController/Routing.html > > Also, you don''t need to wait three days before asking for help. If a > couple of hours of Googling doesn''t solve it, you''re probably about > ready for new eyes on your problem :-)-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The best book in my opinion is Agile Web Development with Rails (then The Rails Way when you get a bit more advanced). Cheers, Andy -- Andy Jeffries http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS Company number: 5452840 On 23 February 2010 22:31, Butterson <jax502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks. Well, I work on my project a few hours a day after work so > it''s not exactly 3 straight days. But you''re right, sometimes Googling > just isn''t enough. I''m glad to have found this group. I''m pretty sure > I''ll have a few more questions later. Any other books you can > recommend for Ruby on Rails? I''m starting to love this new framework > after just a few days of experimenting and would like to continue > going deeper. I currently have Simply Rails 2 by Patrick Lenz and > Learning Rails by St. Laurent & Dumbill. > > On Feb 23, 3:46 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 23 February 2010 20:16, Butterson <jax...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Uggh! I can''t believe it''s that missing ''s'' that was causing me > > > heartache. I also changed ''content'' to ''contents'' and it''s working > > > fine after the update. I guess I need to read more about this > > > routes.rb file. I still don''t have a 100% grasp on it. Thanks all for > > > your help. > > > > Pleasure. > > > > http://api.rubyonrails.org/classes/ActionController/Routing.html > > > > Also, you don''t need to wait three days before asking for help. If a > > couple of hours of Googling doesn''t solve it, you''re probably about > > ready for new eyes on your problem :-) > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 February 2010 21:31, Butterson <jax502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Any other books you can recommend for Ruby on Rails?"Agile Web Development with Rails" was my first introduction, and it still proves to be very useful. I was frustrated by "The Rails Way" (or at least the edition I had) as it was peppered with typos - and when you''re trying to learn a programming language, errors in the example code are frustrating. Another great medium-level book is "Ruby for Rails" (if you can ignore the cover!). It does skim the basics, but then gets on with the good stuff. I can''t recommend highly enough "Refactoring: Ruby Edition" - not strictly a Rails book, but very good for developing your programming skills generally, and Ruby specifically. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.