Active Admin Scope with rails 4.1
You should define your scope using a proc
.
class ClassList < ActiveRecord::Base
scope :upcoming_classes, proc { where('class_date > ?', Date.today) }
end
Rails 4+ expects scopes to be wrapped with a callable object, which is usually defined as a proc
. See the Active Record Query Interface: Scopes documentation; there they use the -> { }
proc syntax.
Active Admin: can't scope the resource to current_admin_user
I found the better solution, then.
Authorization adapter do just fine, and there is not need for scopes. For example, with CanCan:
class Ability
include CanCan::Ability
def initialize(user)
#read/manage actions
if user.role == 'manager'
can :manage, Payment, :accessible_by_manager => true
elsif user.role == 'accountant'
can :read, Payment, :accessible_by_accountant => true
else
#can read all
can :read, Payment
end
end
end
Rails 4 ActiveAdmin - undefined local variable or method `collection_before_scope'
The problem was in my ApplicationController, in this code:
class ApplicationController < ActionController::Base
before_action :set_service_pages
# ...
def set_service_pages
@service_pages = ServicePage.published
end
end
If I change the @service_pages variable name, all starts to work again. So the solution for me was to add
controller do
skip_before_filter :set_service_pages
end
in my ActiveAdmin's ServicePage resource.
By the way, why does ActiveAdmin even care about my variable names?
ActiveAdmin 0.4.3 Rails 3.2.3 Upgrade Error
Try this in your config block:
ActiveAdmin.setup do | config |
...
config.logout_link_path = :signout_path
...
end
Cheers.
Related Topics
How to Programmatically Check If a Certificate Has Been Revoked
Ruby Mailer Is Coming Up with an Eoferror
How to Split String into Array as Integers
What Are Symbols and How Do We Use Them
Ruby: Differencebetween the Comparatives: "||" and "Or"
Ruby Map Method Syntax Question
How to Remove Blank Values Params from Query String
Rails 4.0.3 Generating Incorrect Asset Paths with Asset_Sync
What's a Rails Plugin, or Ruby Gem, to Automatically Fix English Grammar
Ruby Variable as Same Object (Pointers)
Is There a Method to Limit/Clamp a Number
What Are the Steps Needed to Create and Publish a Rubygem of Your Own
Paperclip File Not Found Error
Spacing Around Parentheses in Ruby
Ruby: How to Write a Bang Method, Like Map