Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Devise: How to access sign up page after signed in?

I am new with rails and i am using "devise" gem for authentication purposes.

At first i add a new user through default sign up page (E.g./users/sign_up)

Then, i made "sign_up" page only available to signed_in users by following instructions from

Devise before filter that prevents access to "new_user_registration_path" unless user is signed-in

Now, after sign in process when i try open sign up page it always directs me to root_path! How can i access sign up page?
My "roots.rb" file as follows:

Example::Application.routes.draw do

  devise_for :users, :controllers => { :registrations => 'registrations'}

  resources :companies

  resources :orders

  resources :customers

  root :to => "welcome#index"

end

Thank you all!

like image 917
Junior rails programmer Avatar asked Dec 28 '10 09:12

Junior rails programmer


1 Answers

I have other decision. Bitterzoet said

As you can see in the devise source if you navigate to the sign_up it executes the before_filter require_no_authentication and this redirects to the root path which you can find here.

You don't need override registration_controller, you can change only your custom registration_controller that echo original registration_controller.

class Admin::RegistrationsController < Devise::RegistrationsController
  layout 'admin'
  prepend_before_filter :require_no_authentication, :only => []
  prepend_before_filter :authenticate_scope!
end
like image 193
pirelly Avatar answered Sep 21 '22 09:09

pirelly