I am new to Rails and I need your help.
I have this:
# config/initializers/cantango.rb
CanTango.config do |config|
config.engines.all :on
# more configuration here...
end
# app/models.User.rb
class User < ActiveRecord::Base
def roles_list
roles_rel = Role.where(:user_id=>self.id)
roles=[]
roles_rel.each do |x|
roles.push(x.name)
end
return roles #return [":reader","writer"] from database
end
end
# app/permits/reader_permits.rb
class ReaderPermit < CanTango::UserPermit
def initialize ability
super
end
protected
def permit_rules
can :read, :all
end
end
In my view I have
<%= link_to 'readddd', "/news/feed/read_full?s=#{g.id}&page_id=#{params[:page_id]}" if user_can?(:read, Newsfeed)%>
but I get an error undefined method 'user_can?' for #<#<Class:0xaf41f50>:0xaf40eac>
Please give me a very simple explanation for my situation, where and what I must write. GitHub doesn’t help me.
Fallow the tutorial here:
https://github.com/kristianmandrup/cantango/wiki/Quickstart
I think you forgot this: Create and register a User model