rosa-build/app/controllers/concerns/strong_params.rb

17 lines
442 B
Ruby
Raw Normal View History

2015-03-12 22:43:13 +00:00
module StrongParams
extend ActiveSupport::Concern
protected
def permit_params(param_name, *accessible)
[param_name].flatten.inject(params.dup) do |pp, name|
pp = pp[name] || ActionController::Parameters.new
end.permit(*accessible.flatten)
2015-03-12 22:43:13 +00:00
end
def subject_params(subject_class, subject = nil)
permit_params(subject_class.name.underscore.to_sym, *policy(subject || subject_class).permitted_attributes)
end
2015-03-12 22:43:13 +00:00
end