How do you designate private or protected attributes in Ruby/Rails?
Are all DB fields automatically attributes, and don’t need to be defined in the Model?
Any recommended tutorials?
Working in Rails 3.0.7.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
attr_protected,attr_accessibleorattr_readonlyThe attr_protected, attr_readonly and attr_accessible macros control what is accepted for mass-assignment. Read those links if you’re not familiar with the difference between those three macros.
Documentation of ActiveRecord model:
http://api.rubyonrails.org/classes/ActiveRecord/Base.html
http://apidock.com/rails/ActiveRecord/Base