Does any one else find it a pain in the butt that in the new edge rails the Model.update method has been made private so throws an error if you use it. Most of the time i find i need to do work on POST params[] before i save them back to the database. I was doing it like this which seemed really nice and easy; @widget = Widget.find(params[:id]) @widget.title = "NEW TITLE" @widget.description = params[:description] @widget.edited_by = session[:user_id] @widget.update() now with edge rails it would seem the only way to do this is (as the update method is private): @widget = Widget.find(params[:id]) @var = [] @var[:title] = "NEW TITLE" @var[:description] = params[:description] @var[:edited_by] = session[:user_id] @widget.update_attributes(@var) Which looks like crap and takes longer to write ...or am i missing something? It seems that the update_attributes method calls the update method internally anyway so was just wondering why they changed this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Nov-08 09:31 UTC
Re: Model.update_attributes vs. Model.update in Edge Rails!
On 8 Nov 2007, at 08:52, Adam Jones wrote:> > > I was doing it like this which seemed really nice and easy; > > @widget = Widget.find(params[:id]) > @widget.title = "NEW TITLE" > @widget.description = params[:description] > @widget.edited_by = session[:user_id] > @widget.update()Why aren''t you calling widget.save ?>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 -~----------~----~----~----~------~----~------~--~---
Adam Jones
2007-Nov-08 09:38 UTC
Re: Model.update_attributes vs. Model.update in Edge Rails!
Thanks, That worked....i had always used update for some reason. On 8/11/2007, at 10:31 PM, Frederick Cheung wrote:> > > On 8 Nov 2007, at 08:52, Adam Jones wrote: > > >> >> >> I was doing it like this which seemed really nice and easy; >> >> @widget = Widget.find(params[:id]) >> @widget.title = "NEW TITLE" >> @widget.description = params[:description] >> @widget.edited_by = session[:user_id] >> @widget.update() > Why aren''t you calling widget.save ? >> > 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 -~----------~----~----~----~------~----~------~--~---