After entering the administrator mode, it /admindisappears from the URL.
This happens for all routes nested inside namespace :admin do.
Example:
- Visit
http://localhost:3000/admin/universitiesdownload view. - But then the URL in this view changes to
http://localhost:3000/universities. - Updating the page without adding it manually
/adminresults in "No route matches."
Server Logs:
Started GET "/admin/universities"
Processing by Admin::UniversitiesController#index as HTML
Rendered admin/universities/index.html.haml within layouts/admin
Rendering admin/universities/index.html.haml within layouts/admin
Route:
namespace :admin do
...
get '/universities', to: 'universities#index', as: :university_index
...
end
rake routes:
admin_university_index GET /admin/universities(.:format) admin/universities
Controller:
class Admin::UniversitiesController < Admin::BaseController
def index
@universities = University.all
end
end
I have inherited the application and itβs hard for me to understand why this is happening. Has anyone else had experience with this before?
UPDATE
Could this be caused by turbopumps?
UPDATE
By request by adding admin/base_controller
class Admin::BaseController < ApplicationController
before_action :admin_only
layout "admin"
private
def admin_only
unless current_user && current_user.role == 'admin'
redirect_to login_url, :notice => "Unauthorized"
end
end
end