I am new to ruby on rails, i am using rails 4 and cancancan, i also using Devise gem. i have 4 different users, Admin, School, Franchise Owner, and regular users, i have an ability model which has this in it:
`class Ability include CanCan::Ability
def initialize(user)
user ||= User.new
if user.admin?
can :manage, :all
elsif user.franOwner?
can [:read], menus
elsif user.school?
can :read, all
else
can :read, :all
cannot [:create], Menu
end
end`
and i have a link that i dont want regular users to see in a index.html.erb
` <% if user.admin? %>
<%= link_to 'New Menu', new_menu_path %>
<% end %>`
but says user is undefined, where do i define this and how? if i can get this working i might be able to replicate for other types of users for different things, and help would be greatly appreciated.