1

I have implemented the devise gem on my app and I want to redirect to a specific path after sign_up. I have this method in the registration_controller.rb but its does not work, it redirects to the root path instead of the specified path. I also have devise :confirmable set up but I'm delaying the sent confirmation email until later.

def after_sign_up_path_for(resource)
  new_transaction_path(session[:registration_params])
end

And returns the following flash notice: translation missing: en.devise.registrations.store.signed_up_but

How can I make this work?

omnikron
  • 2,211
  • 17
  • 30
Theopap
  • 715
  • 1
  • 10
  • 33
  • what is in session[:registration_params] ? may be you need to pass resource – Vishal Jul 24 '17 at 13:42
  • you can also try def `after_inactive_sign_up_path_for(resource) new_transaction_path(resource) end` – Vishal Jul 24 '17 at 13:43
  • Thanks for the reply @Vishal.... I'm adding parameters in a query string to a path that it's new_store_registration, and storing them in a sessions when hitting the new action in the store_registration controller and then retrieve them in the after_sign_up_path_for method. – Theopap Jul 24 '17 at 13:52
  • The `def after_inactive_sign_up_path_for(resource) new_transaction_path(session[:registration_params]) end` redirects me to the correct path but does not keep the params – Theopap Jul 24 '17 at 13:54
  • may be you don't have any params in `session[:registration_params] `. try to send `params[:registration]` when you hit sign up button that time in rails server log you can check how params pass in sign up method – Vishal Jul 25 '17 at 05:06

2 Answers2

0

You must be over riding the method in another file. Try searching project wide for after_sign_in_path_for. I have the following in my application controller working perfectly:

class ApplicationController < ActionController::Base
  def after_sign_in_path_for(*)
    cms_path
  end
end

Where cms_path is a named route in my routes file. If yours isn't working you must be over riding it somewhere else.

Mark
  • 6,112
  • 4
  • 21
  • 46
0

I got this to work by adding the following on the registration_controller.rb

def after_inactive_sign_up_path_for(resource)
  new_transaction_path(session[:registration_params])
end
Theopap
  • 715
  • 1
  • 10
  • 33