Now you can say: class Song < ActiveRecord::Base attr_accessor :virtual_attribute assignable_values_for :virtual_attribute do %w[air fluff] end
...your model to have it automatically strip all :string fields before validation: class Organisation < ActiveRecord::Base validates_presence_of :name, :city, :phone, :website, .... does 'strip_string_fields' end
...order to whitelist #id on a model of your choice like this: class MyModel < ActiveRecord::Base include AllowSettingIdOnCreate end Note that your controllers should always whitelist the attributes they set...
Best results in other decks
Modularity Consider the following example from the Modularity README: # app/models/article.rb class Article < ActiveRecord::Base include DoesStripFields[:name, :brand] end # app/models/shared/does_strip_fields.rb module DoesStripFields as_trait do |*fields| fields.each do...