问题描述
使用Rails 5.0.0.beta1。
Using Rails 5.0.0.beta1.
已安装Active Admin和Devise。以下是Gemfile的内容:
Installed Active Admin and Devise. Here is Gemfile contents:
# Backend
gem 'activeadmin', '~> 1.0.0.pre2'
# Authentication
# Master branch is added for Rails 5 support
# https://github.com/plataformatec/devise/pull/3714
gem "devise", :github => 'plataformatec/devise', :branch => 'master'
按照说明安装。
rails g active_admin:install User
rake db:migrate
rake db:seed
rails server
当我尝试输入 / admin
时,出现以下错误:
When I'm trying to enter /admin
, the following error appears:
无法找到输入类Input
Unable to find input class Input
提取的源(在#332行附近):
提高Formtastic :: UnknownInputError,无法找到输入#{$ !. message}
Extracted source (around line #332): raise Formtastic::UnknownInputError, "Unable to find input #{$!.message}"
如果我们查看 activeadmin-1.0.0.pre2 / app / views /active_admin/devise/sessions/new.html.erb
(第10行),没有特别说明al在这里:
If we look at activeadmin-1.0.0.pre2/app/views/active_admin/devise/sessions/new.html.erb
(line #10), nothing special is here:
f.input :password, label: t('active_admin.devise.password.title')
怎么了?也许Formtastic类由于某种原因未自动加载?我试图将Formtastic更新到最新版本,但仍然存在错误。
What's wrong? Maybe Formtastic classes are not autoloaded for some reason? I tried to update Formtastic to the latest version, but error still remains.
我知道使用Beta冒险,但我想尝试一下。
I understand that using beta is kind of risky, but I want to try this out.
推荐答案
弄清楚了。以下是可用的选项:
Figured it out. Here are the available options:
1)可能是最好的选择。只需使用Rails 4.2.5,然后等待Rails 5的稳定发行并根据gem更新即可。
1) Probably the best option. Just use Rails 4.2.5 and wait for stable release of Rails 5 and according gem updates.
2)创建文件 app / active_admin / inputs / input.rb
,其中包含以下内容:
2) Create the file app/active_admin/inputs/input.rb
with the following contents:
module ActiveAdmin
module Inputs
class Input < ::Formtastic::Inputs::StringInput
end
end
end
相关信息可用。
它解决了访问登录页面错误,您现在可以成功登录并查看仪表板。但是,例如,如果尝试输入用户部分,则会出现另一个错误:
It solves accessing login page error, you can now successfully login and view dashboard. However, if you try to enter Users section for example, you get another error:
这是因为在Rails 5中 ActionController :: Parameters
更长的扩展了 ActiveSupport :: HashWithIndifferentAccess
,其中包括 Enumerable
(其中包含方法)。
,但我认为这不是您会遇到的唯一错误。
This is because ActionController::Parameters
in Rails 5 no longer extends ActiveSupport::HashWithIndifferentAccess
which includes Enumerable
(which contains method flat_map).But I think this is not the only one error you will struggle with.
3)此错误, 2)和其他一些错误已在rails-5-spec 分支上得到修复/ activeadmin / pull / 4254 rel = nofollow>此拉取请求,所以我改在Gemfile中使用它:
3) This error, error mentioned in 2) and some other errors were fixed already on rails-5-spec
branch in this pull request, so I switched to using it instead in Gemfile:
gem 'activeadmin', :github => 'activeadmin/activeadmin', :branch => 'rails-5-rspec'
现在错误消失了。
更新::我选择了第3 选项,它解决了开发服务器上的问题,但是当我将应用程序部署到生产环境时,错误再次出现。我使用了 2)中提到的修复程序,现在在生产服务器上也可以。
Update: I choose 3rd option and it solves the problem on development server, but when I deployed application to production, error appeared again. I used the fix mentioned in 2) and now it's OK on production server too.
这篇关于ActiveAdmin :: Devise :: Sessions#new中的Formtastic :: UnknownInputError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!