1
votes

My Rails 5.2, Devise 4.7 app has the standard single sign_in page for new devise sessions.

I want the user to be able to browse a few different pages before signing in, and for each page to have the sign in form on it.

How can I display the devise form for new sessions in the views of other controller actions? Is there a way to run the code from the Devise::SessionsController#new action, from my other controllers? Or do I need to keep a single signin page for new sessions and then add custom things to the page via separate ajax actions?

2

2 Answers

0
votes

I think you have a three ways:

  1. You can create custom popup with same form but change form to remote and also change your form_for accordingly.
  2. You can add ajax processing to Devise::SessionsController#new action (add respond_to and create js template to render it) and then call this action on needed pages.
  3. Move to React/Angular/Vue
0
votes

I put an empty <div id="preview_here"</div> in app/views/devise/sessions/new.html.erb and it gets populated from ajax calls (to non-Devise controllers with skip_before_action :authenticate_user!)