Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:10:12+00:00 2026-05-26T11:10:12+00:00

I am new to Rails and I need your help. I have this: #

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:10:13+00:00Added an answer on May 26, 2026 at 11:10 am

    Fallow the tutorial here:
    https://github.com/kristianmandrup/cantango/wiki/Quickstart

    I think you forgot this: Create and register a User model

    First you must have a User model. Use the tango_user macro in order to
    register a user class with CanTango. CanTango will then generate User
    APIs methods such as #user_can? for the User class, admin_can? for a
    registered Admin user class etc.

    class User
      # register as a "user class" for CanTango
      tango_user
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am bit new with Rails (3.) and need your help to use renamed
I'm new to rails and need your help for what should be a simple
I'm new in rails and need some help creating a Nested form. I have
i really need you guys your help. I have to do animation on a
So I am fairly new to Rails and I need some help. I need
I'm new to Rails and I know a bit of Jquery. I need a
Starting a new rails project and we have a well-thought-out color palette, and want
I am new to ruby on rails. Could you please help me to install
When you are developing a new Rails application, is it preferable to build your
I'm completely new to Ruby on Rails, have never worked on it, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.