I have a PagesController that handles all the static pages of my application. It has a method called join_session
which renders the view pages/page_a.html.erb
. This works.
My problem: I'm writing a method that renders the last viewed page when the user logs back in (using the Devise hook after_database_authentication
in the User
model).
Can I call the PagesController
join_session
method from the User
model?
[I couldn't figure out how to do that, so I tried a hacky workaround: writing and calling a class method in PagesController, and rendering the view there, but since the name of the new method did not match the name of the controller method in the route, the variables in the view could not be resolved.]
My route:
get 'pages/page_a', to: 'pages#join_session'
Help would be much appreciated! :)