Note that there are some explanatory texts on larger screens.

plurals
  1. PODEVISE after_inactive_sign_up_path_for not being called
    text
    copied!<p>Environment: RAILS 3.2 + DEVISE for auth + Invitable + Confirmable add-ons.</p> <pre><code>Using devise (2.2.3) Using devise-i18n (0.6.5) Using devise_invitable (1.0.3) </code></pre> <p>I am trying to redirect to a specific location after ACCEPT (TO SIGN UP), but only <code>after_sign_in_path_for</code> seems to be called after SIGN IN and ACCEPT.</p> <p>I haven't been able to have <code>after_accept_path_for</code> working. It continues to redirect to the "after sign in" location.</p> <p>HERE THE CODE</p> <p>In my routes.rb:</p> <pre><code>devise_for :users, :controllers =&gt; { :registrations =&gt; 'registrations', :invitations =&gt; 'invitations' } </code></pre> <p><code>rake routes</code> give me this:</p> <pre><code> new_user_session GET /users/sign_in(.:format) devise/sessions#new user_session POST /users/sign_in(.:format) devise/sessions#create destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy user_password POST /users/password(.:format) devise/passwords#create new_user_password GET /users/password/new(.:format) devise/passwords#new edit_user_password GET /users/password/edit(.:format) devise/passwords#edit PUT /users/password(.:format) devise/passwords#update cancel_user_registration GET /users/cancel(.:format) registrations#cancel user_registration POST /users(.:format) registrations#create new_user_registration GET /users/sign_up(.:format) registrations#new edit_user_registration GET /users/edit(.:format) registrations#edit PUT /users(.:format) registrations#update DELETE /users(.:format) registrations#destroy user_confirmation POST /users/confirmation(.:format) devise/confirmations#create new_user_confirmation GET /users/confirmation/new(.:format) devise/confirmations#new GET /users/confirmation(.:format) devise/confirmations#show accept_user_invitation GET /users/invitation/accept(.:format) devise/invitations#edit user_invitation POST /users/invitation(.:format) devise/invitations#create new_user_invitation GET /users/invitation/new(.:format) devise/invitations#new PUT /users/invitation(.:format) devise/invitations#update </code></pre> <p>In my registration controller:</p> <pre><code>class RegistrationsController &lt; Devise::RegistrationsController # clear session def create super session[:omniauth] = nil unless @user.new_record? end #protected # after_sign_up_path_for doesn't seem to be called when using Confirmable module # def after_inactive_sign_up_path_for(resource) # #me_path # session[:user_return_to].nil? ? me_path : session[:user_return_to] # end private def build_resource(*args) super if session[:omniauth] @user.apply_omniauth(session[:omniauth]) @user.valid? end end end </code></pre> <p>Also</p> <pre><code>class Users::InvitationsController &lt; Devise::InvitationsController protected def after_accept_path_for session[:user_return_to].nil? ? me_path : session[:user_return_to] end end </code></pre> <p>In my application controller, (I left intentionally some commented code I tried to make it work):</p> <pre><code> def store_location session[:user_return_to] = request.fullpath end # def after_sign_up_path_for # me_path # end # # def after_inactive_sign_up_path_for(resource) # me_path # #session[:user_return_to].nil? ? me_path : session[:user_return_to] # end # https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration) def after_sign_in_path_for(resource) me_path #dashboard_path #session[:user_return_to].nil? ? dashboard_path : session[:user_return_to] end </code></pre> <p>Any suggestions?</p> <p>ADDED DEBUGGIN REDIRECTS</p> <p>Add this to my application_controller</p> <pre><code> def redirect_to_with_logging(*args) logger.debug "Redirect: #{args.inspect} from #{caller[0]}" redirect_to_without_logging *args end alias_method_chain :redirect_to, :logging </code></pre> <p>After Sign in, works like a charm</p> <pre><code>Started POST "/users/sign_in" for 127.0.0.1 at 2013-04-25 14:20:04 +0200 Processing by Devise::SessionsController#create as HTML [... I removed some of the Session creation info ...] Redirect: ["/dashboard"] from /Users/joel/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/action_controller/metal/responder.rb:135:in `redirect_to' Redirected to http://localhost:3000/dashboard Completed 302 Found in 968ms (ActiveRecord: 0.0ms) </code></pre> <p>DOCS:</p> <p><a href="https://github.com/plataformatec/devise/wiki/How-To%3a-Redirect-to-a-specific-page-on-successful-sign-in" rel="nofollow">After sign in</a> </p> <p><a href="https://github.com/plataformatec/devise/wiki/How-To%3a-Redirect-to-a-specific-page-on-successful-sign-up-%28registration%29" rel="nofollow">After sign up</a></p> <p><a href="https://github.com/scambra/devise_invitable#integration-in-a-rails-application" rel="nofollow">After Accept</a> &lt;==== </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload