Im currently learning ROR and have bumped into a small issue regarding different root pages depending on the user type. In my user model i have an attribute for admin which is either true or false depending on the user.
Please see my routes file below, currently all users aways go to 'houses#index', even if they have admin set as false.
I cannot see where i am going wrong in my routes file.
Is there anyway to add a condition for attribute admin on authenicated user in my routes file?
Routes.rb
Rails.application.routes.draw do
devise_for :user
get 'welcome/index'
resources :houses
resources :tenants
resources :requests
authenticated :user do
root 'houses#index', as: "authenticated_root"
end
authenticated :user, {admin:'false'} do
root 'requests#index', as: "authenticated_root1"
end
root 'welcome#index'
end
model\User.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :houses
has_many :tenants
has_many :requests
def admin?
admin
end
end
Thanks.