after that you could use attr_accessible in you models like in Rails 3. Also, and i think that is the best way- using form objects for dealing with mass assignment, and saving nested objects, and you can also use protected_attributes gem that way.
attr_accessible(*attributes) public Specifies a white list of model attributes that can be set via mass-assignment, such as new ( attributes ) , update_attributes ( attributes ) , or attributes= ( attributes ), attr_accessible(*args) public Specifies a white list of model attributes that can be set via mass-assignment. Like attr_protected, a role for the attributes is optional, if.
attr_accessor is used when you do not have a column in your database, but still want to show a field in your forms. This field is a virtual attribute in a Rails model. virtual attribute an attribute not corresponding to a column in the database. attr_accessible. Source code.
I am somewhat new to rails and I am trying to create a User login. I went through the tutorial found here. At the end it had me add attr_accessible for mass assignment. However when I did that I got the following error: undefined method `attr _accessible’ for # I saw on this post that I neeed < ActiveRecord::Base. But I ...ruby on rails - Difference between attr_accessor and attr_accessible ...ruby on rails - Difference between attr_accessor and attr_accessible ...ruby on rails - Difference between attr_accessor and attr_accessible ...attr_accessible is a Rails method that allows you to pass in values to a mass assignment: new(attrs) or update_attributes(attrs). Here's a mass assignment: Order.new({ :type => ‘Corn’, :quantity => 6 }) You can imagine that the order might also have a discount code, say :price_off.
attr_accessible :avatar. Could you please put a note for rails 4 users not to add attr accessible .. causes a undefined method `flush_errors’ for #