hi all, im having a table called employees in db.the table hava five columns as 1.username 2.password 3.firstname 4.lastname 5.mailid. in this i want to update only password column.how to do it.people knows it please help me. -- 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 -~----------~----~----~----~------~----~------~--~---
On 8 Apr 2008, at 10:06, Karthikragunath Bhavani wrote:> > > > hi all, > > im having a table called employees in db.the table hava five > columns as > > 1.username > 2.password > 3.firstname > 4.lastname > 5.mailid. > > in this i want to update only password column.how to do > it.people knows it please help me.ActiveRecord does have an update_attribute method, however (despite the name) it saves the whole record. You can probably force it to save less if you had loaded the record with a more restrictive :select. Or you can drop down a level and use Employee.update_all Fred> > -- > 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 -~----------~----~----~----~------~----~------~--~---
u can do update like Employee.update_attributes(:password => params[:employee][:password]) :) On Tue, Apr 8, 2008 at 2:50 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 8 Apr 2008, at 10:06, Karthikragunath Bhavani wrote: > > > > > > > > > hi all, > > > > im having a table called employees in db.the table hava five > > columns as > > > > 1.username > > 2.password > > 3.firstname > > 4.lastname > > 5.mailid. > > > > in this i want to update only password column.how to do > > it.people knows it please help me. > > ActiveRecord does have an update_attribute method, however (despite > the name) it saves the whole record. You can probably force it to save > less if you had loaded the record with a more restrictive :select. Or > you can drop down a level and use Employee.update_all > > Fred > > > > -- > > 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 -~----------~----~----~----~------~----~------~--~---
It''s also worth nothing that the next release of Rails (2.1) will do just the kind of save you''re asking about. If this is not an immediate production demand it may be worth coding with the standard methods in the short term and absorb the penalty hit and getting the functionality for free when 2.1 is released. On Apr 8, 5:20 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8 Apr 2008, at 10:06, Karthikragunath Bhavani wrote: > > > > > > > hi all, > > > im having a table called employees in db.the table hava five > > columns as > > > 1.username > > 2.password > > 3.firstname > > 4.lastname > > 5.mailid. > > > in this i want to update only password column.how to do > > it.people knows it please help me. > > ActiveRecord does have an update_attribute method, however (despite > the name) it saves the whole record. You can probably force it to save > less if you had loaded the record with a more restrictive :select. Or > you can drop down a level and use Employee.update_all > > Fred > > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthikragunath Bhavani wrote:> > > hi all, > > im having a table called employees in db.the table hava five > columns as > > 1.username > 2.password > 3.firstname > 4.lastname > 5.mailid. > > in this i want to update only password column.how to do > it.people knows it please help me.If nothing else helps, you can do this, Employee.connection.execute("update employees set password=''superseekret'' where id=123") (Look up some means to prevent SQL-Injection.) Stephan -- 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 -~----------~----~----~----~------~----~------~--~---