I''m going though the paper back edition of agile development with Rails. On page #128 I encountered following lines of code: attr_accessor :password attr_accessible :name,:password What''s the difference between attr_accessor and attr_accessible? -=- Neeraj _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Francois Beausoleil
2005-Oct-14 07:03 UTC
Re: Diff between attr_accessible and attr_accessor
Hi ! 2005/10/14, Neeraj Kumar <neeraj.jsr@gmail.com>:> I'm going though the paper back edition of agile development with Rails. On > page #128 I encountered following lines of code: > > attr_accessor :password > attr_accessible :name,:password > > What's the difference between attr_accessor and attr_accessible?attr_accessor creates two methods in the class: def password=(newp) @password = newp end def password @password end attr_accessible is an ActiveRecord method to say that the attributes listed can be mass assigned using new and update_attributes. attr_accessor: http://www.ruby-doc.org/core/classes/Module.html#M000725 attr_accessible: http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000688 Hope that helps ! François _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails