I am sort of in a catch22 situation.
Is there a way to accomplish all three needs?
Thank you.
There are a few ways around mass assignment but I'm not really a fan of them.
For example:
role = Role.new
role.assign_attributes({...}, :without_protection => true)
role.save
I prefer to use a gem I wrote called sudo_attributes that gives you "sudo" privileges:
Role.sudo_create(...)
The API is identical to ActiveRecord's for creating and instantiating models.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.