未定义的方法“重新排序”对于#<数组 :0xbc38600>使用 ActiveAdmin

发布于 2025-01-07 18:37:20 字数 14754 浏览 0 评论 0原文

我在使用 Ruby ruby​​ 1.9.2p290 和 Ruby on Rails 3.2.1 时遇到 ActiveAdmin 问题。

我使用此 wiki 页面为 AdminUsers 设置完美运行的资源: 您的第一个管理资源:AdminUser

之后,我想为我的项目模型创建资源。迁移看起来像这样:

class CreateProjects < ActiveRecord::Migration
  def change
    create_table :projects do |t|
      t.string :name
      t.text :description
      t.boolean :isactive

      t.timestamps
    end
  end
end

class AddSlugToProjects < ActiveRecord::Migration
  def change
    add_column :projects, :slug, :string
    add_index :projects, :slug
  end
end

我的项​​目模型:

class Project < ActiveRecord::Base

  scope :isactive, :conditions => ["isactive = ?",true]

  extend FriendlyId
  friendly_id :name, use: [:slugged, :history]

  attr_accessible :name, :description, :isactive

end

这就是 project_controller:

class ProjectsController < ApplicationController

  def index
    #
    # @projects gets filled in application_controller to be always
    # available for the twitter bootstrap navbar
    # @projects = Project.isactive.find(:all, :order => 'LOWER(name) asc')
    #
  end

  def show
    @project = Project.isactive.find(params[:id])
    if request.path != project_path(@project)
      redirect_to @project, :status => :moved_permanently
    end
  end

end

admin/projects.rb 当前为“空”

ActiveAdmin.register Project do  
end

毕竟,我得到的一切都是以下错误:

Started GET "/admin/projects" for 192.168.0.2 at 2012-02-21 20:58:49 +0100
Processing by Admin::ProjectsController#index as HTML
  Project Load (0.1ms)  SELECT "projects".* FROM "projects" WHERE (isactive = 't') ORDER BY LOWER(name) asc
  AdminUser Load (0.1ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 2 LIMIT 1
  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.1/app/views/active_admin/resource/index.html.arb (11.7ms)
Completed 500 Internal Server Error in 54ms

ActionView::Template::Error (undefined method `reorder' for #<Array:0xa3ecd44>):
    1: render renderer_for(:index)
  activeadmin (0.4.1) lib/active_admin/views/pages/index.rb:41:in `items_in_collection?'
  activeadmin (0.4.1) lib/active_admin/views/pages/index.rb:20:in `main_content'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:116:in `block (2 levels) in build_main_content_wrapper'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:115:in `block in build_main_content_wrapper'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:114:in `build_main_content_wrapper'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:98:in `block in build_page_content'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:97:in `build_page_content'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:41:in `block (2 levels) in build_page'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:38:in `block in build_page'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:37:in `build_page'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:10:in `build'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:63:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:41:in `method_missing'
  activeadmin (0.4.1) lib/active_admin/view_helpers/renderer_helper.rb:21:in `render'
  activeadmin (0.4.1) app/views/active_admin/resource/index.html.arb:1:in `__home_eins____rbenv_versions_______p____lib_ruby_gems_______gems_activeadmin_______app_views_active_admin_resource_index_html_arb___523541447_100786690'
  actionpack (3.2.1) lib/action_view/template.rb:143:in `block in render'
  activesupport (3.2.1) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.1) lib/action_view/template.rb:141:in `render'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:41:in `block (2 levels) in render_template'
  actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:40:in `block in render_template'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:48:in `render_with_layout'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:39:in `render_template'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:12:in `render'
  actionpack (3.2.1) lib/action_view/renderer/renderer.rb:36:in `render_template'
  actionpack (3.2.1) lib/action_view/renderer/renderer.rb:17:in `render'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:109:in `_render_template'
  actionpack (3.2.1) lib/action_controller/metal/streaming.rb:225:in `_render_template'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:103:in `render_to_body'
  actionpack (3.2.1) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
  actionpack (3.2.1) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:88:in `render'
  actionpack (3.2.1) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
  activesupport (3.2.1) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
  activesupport (3.2.1) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
  activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:39:in `render'
  activeadmin (0.4.1) lib/active_admin/resource_controller/actions.rb:13:in `block (2 levels) in index'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:229:in `call'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:229:in `default_render'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:160:in `to_html'
  responders (0.6.5) lib/responders/flash_responder.rb:93:in `to_html'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:153:in `respond'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:146:in `call'
  actionpack (3.2.1) lib/action_controller/metal/mime_responds.rb:238:in `respond_with'
  inherited_resources (1.3.0) lib/inherited_resources/actions.rb:7:in `index'
  activeadmin (0.4.1) lib/active_admin/resource_controller/actions.rb:11:in `index'
  actionpack (3.2.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.1) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.1) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.1) lib/active_support/callbacks.rb:469:in `_run__639476650__process_action__1068992826__callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
  activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.1) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.1) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.1) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `call'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:30:in `call'
  journey (1.0.1) lib/journey/router.rb:68:in `block in call'
  journey (1.0.1) lib/journey/router.rb:56:in `each'
  journey (1.0.1) lib/journey/router.rb:56:in `call'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:in `call'
  sass (3.1.15) lib/sass/plugin/rack.rb:54:in `call'
  warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.1.1) lib/warden/manager.rb:34:in `catch'
  warden (1.1.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/cookies.rb:338:in `call'
  activerecord (3.2.1) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__471556791__call__937320005__callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
  railties (3.2.1) lib/rails/engine.rb:479:in `call'
  railties (3.2.1) lib/rails/application.rb:220:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'


  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.1ms)
  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.1ms)
  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (9.8ms)

我不知道问题是什么...

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 perfectly: Your First Admin Resource: AdminUser

After that I wanted to create the resource for my project model. The migrations for that looks like this:

class CreateProjects < ActiveRecord::Migration
  def change
    create_table :projects do |t|
      t.string :name
      t.text :description
      t.boolean :isactive

      t.timestamps
    end
  end
end

class AddSlugToProjects < ActiveRecord::Migration
  def change
    add_column :projects, :slug, :string
    add_index :projects, :slug
  end
end

My project model:

class Project < ActiveRecord::Base

  scope :isactive, :conditions => ["isactive = ?",true]

  extend FriendlyId
  friendly_id :name, use: [:slugged, :history]

  attr_accessible :name, :description, :isactive

end

And that's the project_controller:

class ProjectsController < ApplicationController

  def index
    #
    # @projects gets filled in application_controller to be always
    # available for the twitter bootstrap navbar
    # @projects = Project.isactive.find(:all, :order => 'LOWER(name) asc')
    #
  end

  def show
    @project = Project.isactive.find(params[:id])
    if request.path != project_path(@project)
      redirect_to @project, :status => :moved_permanently
    end
  end

end

The admin/projects.rb is currently 'empty'

ActiveAdmin.register Project do  
end

And after all that, everything I get is the following error:

Started GET "/admin/projects" for 192.168.0.2 at 2012-02-21 20:58:49 +0100
Processing by Admin::ProjectsController#index as HTML
  Project Load (0.1ms)  SELECT "projects".* FROM "projects" WHERE (isactive = 't') ORDER BY LOWER(name) asc
  AdminUser Load (0.1ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 2 LIMIT 1
  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.1/app/views/active_admin/resource/index.html.arb (11.7ms)
Completed 500 Internal Server Error in 54ms

ActionView::Template::Error (undefined method `reorder' for #<Array:0xa3ecd44>):
    1: render renderer_for(:index)
  activeadmin (0.4.1) lib/active_admin/views/pages/index.rb:41:in `items_in_collection?'
  activeadmin (0.4.1) lib/active_admin/views/pages/index.rb:20:in `main_content'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:116:in `block (2 levels) in build_main_content_wrapper'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:115:in `block in build_main_content_wrapper'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:114:in `build_main_content_wrapper'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:98:in `block in build_page_content'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:97:in `build_page_content'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:41:in `block (2 levels) in build_page'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:68:in `block in build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:67:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/html/element.rb:17:in `div'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:38:in `block in build_page'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:96:in `with_current_dom_context'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:37:in `build_page'
  activeadmin (0.4.1) lib/active_admin/views/pages/base.rb:10:in `build'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:63:in `build_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:77:in `insert_tag'
  activeadmin (0.4.1) lib/active_admin/arbre/builder.rb:41:in `method_missing'
  activeadmin (0.4.1) lib/active_admin/view_helpers/renderer_helper.rb:21:in `render'
  activeadmin (0.4.1) app/views/active_admin/resource/index.html.arb:1:in `__home_eins____rbenv_versions_______p____lib_ruby_gems_______gems_activeadmin_______app_views_active_admin_resource_index_html_arb___523541447_100786690'
  actionpack (3.2.1) lib/action_view/template.rb:143:in `block in render'
  activesupport (3.2.1) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.1) lib/action_view/template.rb:141:in `render'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:41:in `block (2 levels) in render_template'
  actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:40:in `block in render_template'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:48:in `render_with_layout'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:39:in `render_template'
  actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:12:in `render'
  actionpack (3.2.1) lib/action_view/renderer/renderer.rb:36:in `render_template'
  actionpack (3.2.1) lib/action_view/renderer/renderer.rb:17:in `render'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:109:in `_render_template'
  actionpack (3.2.1) lib/action_controller/metal/streaming.rb:225:in `_render_template'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:103:in `render_to_body'
  actionpack (3.2.1) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
  actionpack (3.2.1) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:88:in `render'
  actionpack (3.2.1) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
  activesupport (3.2.1) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
  activesupport (3.2.1) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
  activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:39:in `render'
  activeadmin (0.4.1) lib/active_admin/resource_controller/actions.rb:13:in `block (2 levels) in index'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:229:in `call'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:229:in `default_render'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:160:in `to_html'
  responders (0.6.5) lib/responders/flash_responder.rb:93:in `to_html'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:153:in `respond'
  actionpack (3.2.1) lib/action_controller/metal/responder.rb:146:in `call'
  actionpack (3.2.1) lib/action_controller/metal/mime_responds.rb:238:in `respond_with'
  inherited_resources (1.3.0) lib/inherited_resources/actions.rb:7:in `index'
  activeadmin (0.4.1) lib/active_admin/resource_controller/actions.rb:11:in `index'
  actionpack (3.2.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.1) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.1) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.1) lib/active_support/callbacks.rb:469:in `_run__639476650__process_action__1068992826__callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.1) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
  activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.1) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.1) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.1) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.1) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `call'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:30:in `call'
  journey (1.0.1) lib/journey/router.rb:68:in `block in call'
  journey (1.0.1) lib/journey/router.rb:56:in `each'
  journey (1.0.1) lib/journey/router.rb:56:in `call'
  actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:in `call'
  sass (3.1.15) lib/sass/plugin/rack.rb:54:in `call'
  warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.1.1) lib/warden/manager.rb:34:in `catch'
  warden (1.1.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/cookies.rb:338:in `call'
  activerecord (3.2.1) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__471556791__call__937320005__callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
  railties (3.2.1) lib/rails/engine.rb:479:in `call'
  railties (3.2.1) lib/rails/application.rb:220:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
  /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'


  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.1ms)
  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.1ms)
  Rendered /home/eins11/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (9.8ms)

And I have no idea what the problem is...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

简单气质女生网名 2025-01-14 18:37:20

啊,我已经找到解决办法了。
我不知道为什么会发生错误,但我必须更改我的 application_controller。

在 application_controller 中,我将所有项目提取到 @projects:

before_filter :getActiveProjects

protected

  def getActiveProjects
    @projects = Project.isactive.find(:all, :order => 'LOWER(name) asc')
  end

这让 ActiveAdmin 感到困惑。在我将其更改为

before_filter :getActiveProjects

protected

  def getActiveProjects
    @projects_all = Project.isactive.find(:all, :order => 'LOWER(name) asc')
  end

和projects_controller索引操作之后,

def index
  @projects = @projects_all
end

一切正常;)

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 ;)

樱花坊 2025-01-14 18:37:20

一个更简单的解决方案是跳过特定活动管理控制器中的过滤器:

ActiveAdmin.register Project do  
    controller do
      skip_before_filter :getActiveProjects
    end
end

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
辞旧 2025-01-14 18:37:20

主动管理员对@resource变量进行特殊处理。其中resource是传递给register方法的相应类名。因此,对于代码:

ActiveAdmin.register Project do  
end

变量的名称是

`@project`

我们不能为具有此类名称的变量赋值。这些变量也可以是 ActiveRecord::Relation 类的对象。 @Oliver 如何写像@projects_all 这样的名字是不错的选择。使用skip_before_filter也可以解决这个问题。

需要检查一件狡猾的事情。资源的控制器可能没有任何过滤器。资源的控制器可能根本不存在。要放在skip_before_filter 中的过滤器名称是什么?那么这样的过滤器在哪里呢?无论如何,都会使用默认的应用程序控制器。过滤器可以安装在主应用控制器处。该问题的错误消息根本没有提供任何信息。因此还需要检查应用程序控制器是否安装了过滤器。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文