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

  • Home
  • SEARCH
  • 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 7592531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:55:49+00:00 2026-05-30T20:55:49+00:00

I have implemented Devise for Authentication and Authorization in ROR application everything seems fine

  • 0

I have implemented Devise for Authentication and Authorization in ROR application everything seems fine but getting one issue.
I have two modals “Account” and “Transactiona” , and so two controllers respectively.

My Transaction Index view call one of Account Controller method like this

$.post("accounts/our_miles_balance/?account_number="+$("#account_number").val(),function(data)
{
   $("#our_miles_balance").val(data);
});

When this ajax post run it gives following error and sign out admin user

You need to sign in or sign up before continuing

Here is my Ability Class

class Ability
include CanCan::Ability

def initialize(user)
  user ||= User.new # guest user
  if user.role == 1 #admin
    can :manage, :all
    can :read, :all
  elsif user.role == 2 #Vendor
    can :manage, VendorTransaction
    can :index, Account
  end
end
end

What i m doing wrong her, please help….

Edit

Ok Here is my Transaction controller

require 'csv'
class TransactionsController < ApplicationController
load_and_authorize_resource
helper_method :sort_column, :sort_direction

respond_to :html, :js
def index
  per_page = 40
  @transactions = Transaction.search(params[:id]).order(sort_column + " " + sort_direction)

 respond_to do |format|
  format.html # index.html.erb
  format.csv { render :csv => @transactions}
end

AND Account Controller

class AccountsController < ApplicationController
load_and_authorize_resource
helper_method :sort_column, :sort_direction
def index
   @accounts = Account.search(params[:program_id]
  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @accounts}
 end

 def our_miles_balance
   a = Account.find_by_account_number(params[:account_number])
   @miles = Account.our_miles_balance(a.id) if ?a!=nil
    respond_to do |format|
     format.json { render json: @miles}
  end
end
end
  • 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-30T20:55:50+00:00Added an answer on May 30, 2026 at 8:55 pm

    When using load_and_authorize_resource, it’s calling authorize!(:our_miles_balance, @account) before the our_miles_balance controller action. Documentation.

    Option 1

    Add

    can :our_miles_balance, Account
    

    to your ability class.

    Option 2

    In the controller do

    load_and_authorize_resource :except => :our_miles_balance
    

    and in the our_miles_balance action do

    authorize! :read, @account
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented authentication systems for webapps several times over the years, but before
I'm working on Ruby on Rails 3 application. Already, I have implemented authentication and
I have implemented a application to check whether bluetooth is ON/OFF using CoreBluetooth.framework but
I have Devise implemented in a Rails 3 application, with the :registerable and :confirmable
I have implemented In App purchase in one of the existing application. I have
I have implemented Devise in a Rails 3 application and I need admin users
I am using the devise gem for authentication and have the following before_filter in
I have created a simple API for a Rails application using token-based-authentication that supports
I have two entities. User and Role. I am using Devise and CanCan. They
I have implemented whole push notification service for my application using easyapns . 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.