On Nov 27, 9:30 pm, bobthabuilda <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to