Question

I need some routes for email confirmation and password reset in Rails for users to click on in emails they receive.

I looked at Railscast #274 - Remember Me & Reset Password and it creates a separate controller for that one Reset action.

Wondering if, because they're both User#email related they might not be better suited as member or collection actions on the User Controller itself?!? Routes like:

/user/reset/:token & /user/confirm/:token or /user/:id/reset/:token & /user/:id/confirm/:token seem plausible but not exactly sure how to create them & what route helper would look like?!?

Or maybe they could both be combined in a single controller? verification/confirm/:token & /verification/reset/:token?

Anyway, just looking for ideas to save me some trial & error. What I don't want is two separate controllers (one for email confirmation and another for password reset).

Was it helpful?

Solution

This can certainly be done, but it's not RESTful. These resources (confirmations, resets) can be better handled by a dedicated controller with simpler, less-brittle code since it would comply with the REST pattern. Convention over configuration as always... If you find this isn't working for your specific case, by all means do it as you see fit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top