0

I would like to raise exceptions when trying to mass-assign an invalid attribute in the production environment, but only for a specific controller.

I figured I should add config.active_record.mass_assignment_sanitizer = :strict to production.rb, but that would raise exceptions app-wide.

Is there a way to only use the strict mode for a specific Controller?

The reason is that in normal usage I don't want the user to be server 500-errors, but there is a critical (data import) section in which I would like to rescue from the mass-assignment error and provide information to the user.

I'm running on Rails 3.2

Roemer
  • 3,566
  • 1
  • 16
  • 32

1 Answers1

1

Sounds like you need to have some exception handling mechanism. You can catch the exception in application_controller and do your checking there.

coderek
  • 1,860
  • 14
  • 20