1
votes

in my rails app I want to redirect users to a path similar to http://localhost:3000/en/profiles/first_name-last_name/edit for this I'm using friendly_id gem, and this is my profile model

extend FriendlyId
friendly_id :full_name, use: :slugged


def full_name
    (self.first_name + " " + self.last_name).titleize
end 

and I have create a registration controller to redirect users, this is my controller

class RegistrationsController < Devise::RegistrationsController protected

def after_sign_up_path_for(resource)
    "/profiles/#{current_user.profile.id}/edit" if current_user
end

end

and this is my routes

scope "(:locale)", locale: /en|fr/ do
  devise_for :users, :controllers => { :registrations => "registrations" } 
end

but after sign up I'm always redirected to the root_path instead of http://localhost:3000/en/profiles/first_name-last_name/edit

1

1 Answers

0
votes

Change your Registration controller to

def after_sign_up_path_for(resource)
    edit_profile_path(current_user.profile) if current_user
end