bobthabuilda
2009-Nov-27 21:30 UTC
attr_accessible & attr_accessor - what''s the difference?
i''m still new to rails and working on digesting everything i come across. recently i came across these two. what is the difference between attr_accessor and attr_accessible? -- 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.
Frederick Cheung
2009-Nov-27 21:50 UTC
Re: attr_accessible & attr_accessor - what''s the difference?
On Nov 27, 9:30 pm, bobthabuilda <john.gra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i''m still new to rails and working on digesting everything i come > across. recently i came across these two. what is the difference > between attr_accessor and attr_accessible?They are completely unrelated. attr_accessible and its counterpart attr_protected are there to help avoid users injecting parameters via mass assignment (ie Model.new would ignore them). attr_accessor is a ruby method that is the combination of attr_reader & attr_accessor: it creates a pair of accessor methods for an instance variable (Don''t use this for database attributes - Rails creates those accessors for you) 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-/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.
Nicholas Wieland
2009-Nov-29 03:01 UTC
Re: Re: attr_accessible & attr_accessor - what''s the difference?
On Nov 27, 2009, at 10:50 PM, Frederick Cheung wrote:> attr_accessor is a ruby method that is the combination of attr_reader > & attr_accessortypo: attr_reader and attr_writer :-) ngw -- 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.