Here’s a basic overview of my domain:
- a user has a list of courses
- the user can “select” a course. The corresponding action is invoked with
the PUT verb, stores the course_id in
a session variable and redirects to
the “show” action of the selected
course. - when the user has only 1 course available, I want to redirect him
directly to the only course available (and
invoke the “select” method before, of
course).
From there, i see 2 options:
- Keep the “select” action when the user clicks the link and add a new action for when the selection is automatic… but that doesn’t look very DRY (even if I could refactor some code)
- call the PUT action from the controller itself… but I haven’t found how (is it even possible)?
Any alternative is welcome 🙂
Thanks for your help.
P.
In the courses controller: