coopdevs / katuma

ABANDONED - Old Katuma's backend API
http://www.katuma.org
21 stars 9 forks source link

Resque from ActionController::ParameterMissing and respond with i18n message for each field #74

Closed andresgutgon closed 8 years ago

andresgutgon commented 8 years ago

WAT

Not necessary validate presence of emails on that layer. Already validated later. Also validating in that moment do not return the error for UI: image

enricostano commented 8 years ago

I would fix the error instead. I think that this is one of those cases where parameters validation in controllers is useful.

andresgutgon commented 8 years ago

I would fix the error instead

How?

enricostano commented 8 years ago

You can catch the error and respond with whatever you want in the controller

andresgutgon commented 8 years ago

Can you point to an example on how to catch that error?

enricostano commented 8 years ago

ActionController::ParameterMissing is the exception raised.

you can use rescue_from inside the controller to add custom behavior http://guides.rubyonrails.org/action_controller_overview.html#rescue-from

enricostano commented 8 years ago

Really nice @edulan && @andresgutgon ! :clap: :+1: