Module: Protector::ActiveRecord::Adapters::StrongParameters
- Defined in:
- lib/protector/adapters/active_record/strong_parameters.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#sanitize_for_mass_assignment(*args) ⇒ Object
strong_parameters integration.
Class Method Details
.sanitize!(args, is_new, meta) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/protector/adapters/active_record/strong_parameters.rb', line 5 def self.sanitize!(args, is_new, ) return if args[0].permitted? if is_new args[0] = args[0].permit(*.access[:create].keys) if .access.include? :create else args[0] = args[0].permit(*.access[:update].keys) if .access.include? :update end end |
Instance Method Details
#sanitize_for_mass_assignment(*args) ⇒ Object
strong_parameters integration
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/protector/adapters/active_record/strong_parameters.rb', line 15 def sanitize_for_mass_assignment(*args) # We check only for updation here since the creation will be handled by relation # (see Protector::Adapters::ActiveRecord::Relation#new_with_protector and # Protector::Adapters::ActiveRecord::Relation#create_with_protector) if Protector.config.strong_parameters? && args.first.respond_to?(:permit) \ && !new_record? && protector_subject? StrongParameters.sanitize! args, false, end super end |