mass-assignment Blogs
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
Kiprosh is now part of LawLytics
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
What is Mass Assignment? Assigning multiple attributes of a record with params received from the application within a single query. For example,{:user => {:first_name => "FirstName", :last_name => "LastName", :role => "admin"}} So while creating a new record in User table, we specify as => User.create(params[:user]) In the above query, rails gives the freedom for one-to-one mapping of params attributes with model-record attributes. Lets say, we don't explicitly specify as User.create(:first_name => params[:user][:first_name], :last_name => params[:user][:last_name].......). Such assignments