|
|
|
|
|
by snprbob86
5439 days ago
|
|
Many of those real-life scenario assertions can be implemented as before/after/around filters, since they apply to many routes. In Rails, :except and :only are super useful on filters. Also, another possibility is to noun-ify some verbs. (Some may prefer to call it resource-ification, or REST-ification) For example, you could create a PasswordResetRequest model, which handles all of the logic for checking the old password, the password confirmation, the new password's complexity, etc. Then it would be responsible for executing the actual password change as well. As a bonus, noun-ification enables easy logging because you'll already have a data structure to store. |
|
Here is a simple example for hooking in route-specific middlewares: https://gist.github.com/978411#file_express_middlewares.coff...