Rails 3:ActiveAdmin Gem 406 HTTP问题

时间:2012-04-10 14:46:49

标签: ruby-on-rails-3 activeadmin

我正在使用一个API系统,我需要一个简单的CRUD操作的快速管理部分。所以我决定安装ActiveAdmin,但是当我转到http://localhost:3000/admin/login时,我收到406不可接受的日志错误和白屏。

我按照activeadmin提供的说明操作,但它无效。其他人遇到这个问题?

以下是我的路线:

TestApp::Application.routes.draw do
  ActiveAdmin.routes(self)

  devise_for :admin_users, ActiveAdmin::Devise.config

  namespace "api" do
    namespace "v1" do

      resources :countries do
        resources :states
      end

      resources :states do
        resources :counties
      end

      resources :counties do
        resources :districts
      end

      resources :districts do
        resources :schools
      end

    end # end v1 Namespace
  end # end api Namespace
end # end TestApp::Application routes

3 个答案:

答案 0 :(得分:1)

对此的修复是注释掉元搜索宝石,然后强制ActiveAdmin使用formtastic~> 2.1.1

gem 'formtastic', '~> 2.1.1'
gem 'activeadmin'
#gem 'meta_search',    '>= 1.1.0.pre'

捆绑命令:

bundle update formtastic

答案 1 :(得分:1)

仅供参考以防万一,我在ActiveAdmin 0.6.3遇到同样的问题。我在尝试更新资源时收到此日志条目:

Started PUT "/admin/brands/117" for 127.0.0.1 at 2014-04-16 13:01:22 -0300
Processing by Admin::BrandsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "brand"=>{"key"=>"Somebrand"}, "commit"=>"Update Brand", "id"=>"117"}
  AdminUser Load (1.1ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 1 LIMIT 1
  Brand Load (1.0ms)  SELECT "brands".* FROM "brands" WHERE "brands"."id" = $1 LIMIT 1  [["id", "117"]]
Completed 406 Not Acceptable in 216.9ms (ActiveRecord: 2.1ms)

原来在Brand模型中无法访问属性,因此Rails决定返回406

答案 2 :(得分:0)

这解决了我的问题

gem 'activeadmin' , '0.4.2'
gem "formtastic", "~> 2.1.1"