hi friends... my rhtml is for_for_test.rhtml <html> <head> <title>Form_For Tester</title> </head> <body> <% form_for :blog, :url => { :action => ''save'', :id => @blog } do |f| %> Name: <%= f.text_field :blog %> <%= submit_tag ''Save'' %> <% end %> </body> </html> controller is def form_for_test @blog= Blog.find[:all] end def save blog = Blog.find(params[:id]) blog.update_attributes(params[:blog]) redirect_to :action => ''form_for_test'' end error msg: Couldn''t find Blog without an ID -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi! just briefly glancing over this but try adding ''.id'' to the :id => on your form_for tag So: <% form_for :blog, :url => { :action => ''save'', :id => @blog.id } do |f| %> Gavin On Nov 20, 9:58 am, Smarty 2k <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hi friends... > my rhtml is for_for_test.rhtml > <html> > <head> > <title>Form_For Tester</title> > </head> > <body> > <% form_for :blog, :url => { :action => ''save'', :id => @blog } do > |f| %> > Name: <%= f.text_field :blog %> > <%= submit_tag ''Save'' %> > <% end %> > </body> > </html> > > controller is > > def form_for_test > @blog= Blog.find[:all] > end > def save > blog = Blog.find(params[:id]) > blog.update_attributes(params[:blog]) > redirect_to :action => ''form_for_test'' > end > > error msg: Couldn''t find Blog without an ID > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 20 Nov 2008, at 09:58, Smarty 2k wrote:> > def form_for_test > @blog= Blog.find[:all] >that''s wrong. You probably meant Blog.find :all or Blog.find(:all) (which are the same) Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well spotted Fred! wouldn''t this be even easier though: @blog = Blog.all Gavin On Nov 20, 10:23 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 20 Nov 2008, at 09:58, Smarty 2k wrote: > > > > > def form_for_test > > @blog= Blog.find[:all] > > that''s wrong. You probably meant Blog.find :all or Blog.find(:all) > (which are the same) > > Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Well spotted Fred! wouldn''t this be even easier though: @blog = Blog.all Gavin On Nov 20, 10:23 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 20 Nov 2008, at 09:58, Smarty 2k wrote: > > > > > def form_for_test > > @blog= Blog.find[:all] > > that''s wrong. You probably meant Blog.find :all or Blog.find(:all) > (which are the same) > > Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 20 Nov 2008, at 11:03, Dr_Gavin wrote:> > > Well spotted Fred! > wouldn''t this be even easier though: > @blog = Blog.allif you''re on 2.1 or higher then yes> > > Gavin > > On Nov 20, 10:23 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 20 Nov 2008, at 09:58, Smarty 2k wrote: >> >> >> >>> def form_for_test >>> @blog= Blog.find[:all] >> >> that''s wrong. You probably meant Blog.find :all or Blog.find(:all) >> (which are the same) >> >> Fred > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---