I have a problem with ActiveAdmin using Ruby ruby 1.9.2p290 and Ruby on Rails 3.2.1.
I used this wiki page to setup the resource for the AdminUsers that works perfec
The active admin make special processing of @resource
variables. Where resource
is correponding class name passed to register method. So for code:
ActiveAdmin.register Project do
end
name of variable is
`@project`
We must not assign value to variable with such name. Also such varibles may be object of ActiveRecord::Relation class. And how @Oliver write the name like @projects_all is good choice. The using of skip_before_filter is solve the problem too.
One crafty thing need to check. The controller of resource may not have any filters. The controller of resource may not exists at all. What is the filter name to put to skip_before_filter? And where is such filters? The default application controller is used anyway. The filter may be installed at main application controller. The error message of this problem is not informative at all. So need to check application controller for installed filters too.
Ah, I've found the solution. I don't know exactly why the error happened but I had to change my application_controller.
In the application_controller I fetched all projects to @projects:
before_filter :getActiveProjects
protected
def getActiveProjects
@projects = Project.isactive.find(:all, :order => 'LOWER(name) asc')
end
That was confusing ActiveAdmin. After I changed that to
before_filter :getActiveProjects
protected
def getActiveProjects
@projects_all = Project.isactive.find(:all, :order => 'LOWER(name) asc')
end
and projects_controller index action to
def index
@projects = @projects_all
end
everything worked fine ;)
An easier solution is to just skip the filter in the particular active admin controller:
ActiveAdmin.register Project do
controller do
skip_before_filter :getActiveProjects
end
end