No, but there is a common template for this case:
class Customer include ActiveModel::MassAssignmentSecurity attr_accessor :name, :credit_rating attr_accessible :name attr_accessible :name, :credit_rating, :as => :admin def assign_attributes(values, options = {}) sanitize_for_mass_assignment(values, options[:as]).each do |k, v| send("#{k}=", v) end end end
This is from here. See link for examples.
If you often repeat this approach, you can extract this method in a separate module and include it on demand.
jdoe
source share