routes - Rails: root to not having desired behavior -
i trying set root 'hello#login', render view corresponding /hello/login/
path. when go root path, after having logged out of site user, 422.html
page render upon rescuing cancan accessdenied exception in event user not logged in, per following code:
rescue_from cancan::accessdenied |exception| if current_user redirect_to dashboard_index_path, :notice => exception.message elsif request.env['path_info'] == '/' render :file => "#{rails.root}/public/422.html", :status => 422, :layout => true else render :file => "#{rails.root}/public/422.html", :status => 422, :layout => false end end
i thought had cancan permissions, realized when manually go /home/login/
path, page displays expected without raising cancan error. believe problem routes.rb
file. doesn't make sense, since basic.
here routes.rb
file:
devise_for :users, activeadmin::devise.config activeadmin.routes(self) resources :users resources :projects resources :entries end resources :entries root to: 'hello#login' match 'dashboard/index' => 'dashboard#index', :as => :dashboard_index match 'hello/login' => 'hello#login', :as => :hello_login
here ability.rb
model file:
class ability include cancan::ability def initialize(user) if user can :manage, :all else cannot :manage, :all end end end
finally here hello
controller. can see, don't make calls authenticate
should getting cancan problems. don't access models fail see why getting behavior getting:
class hellocontroller < applicationcontroller def login end end
thanks help!
micha'el.
Comments
Post a Comment