1
votes

i am new to rails and any advise and help will be much appreciated.

I am currently using devise confirmable

When a user signs up for the first time they get:

  • Re-directed to the application root at localhost:3000
  • Flash notice saying "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."

So far so good.

I am trying to redirect the user to a different page when they signup but unsure how - any advise would be much appreciated

application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  before_filter :configure_permitted_parameters, if: :devise_controller?

  protected
  def after_sign_in_path_for(resources)
    if userr_signed_in?
      dashboard_path
    elsif usera_signed_in?
      admin_path
    else
      dashboardj_path
    end
  end

  def after_sign_out_path_for(resources)
    new_feedback_path
  end

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email) }
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:category_businesstype_id, :firstname, :lastname, :companyname, :email, :password, :category_role_id, :staff, :number, :hear, :city, :category_qualification_id, :language, :category_careerlevel_id, :desiredjob, :category_distance_id, :category_cvpreference_id, :category_joboption_id, :preferedlocation, :category_notice_id, :category_country_id, :category_positiontype_id ) }
  end
end
1

1 Answers

3
votes

According to your case, you want to redirect user after signup on a specific path. For that you need to override after_sign_up_path instead of after_sign_in_path.

In application controller you should have this method

def after_sign_up_path_for(resource)
  after_registration_path // Your path should goes here
end

After sign_in path can only be used when you are trying to actually log in user to your system immediately after registration. Here you have to just redirect a user.