我已将active_admin更新为0.3.0版,以实现国际化.但我有问题.
我使用activeadmin部分更新了我的pl.yml文件,如下所示:
pl:
active_admin:
blank_slate:
content: "Nie ma jeszcze rekordów."
link: "Nowy"
dashboard: "Dashboard2"
view: "Podgl?d"
Run Code Online (Sandbox Code Playgroud)
这不起作用,所以我尝试将此代码添加到我的application.rb:
config.before_configuration do
I18n.locale = :pl
I18n.load_path += Dir[Rails.root.join('config', 'locales', '*', '.{rb,yml}')]
I18n.reload!
end
Run Code Online (Sandbox Code Playgroud)
现在国际化似乎在开发环境中起作用,但我在其他环境中仍然存在问题.我的仪表板有问题:关键.通常,简而言之,当I18n找不到密钥时,它会输入密钥:使用大写字母,在本例中它将是"仪表板".但就我而言,我有这样的事情:
DEVELOMENT:

生产:

有没有人有同样的问题?我做错了什么,或者这是一个activeadmin错误?有解决方案吗
我有这个:
ActiveAdmin.register User do
controller do
def show
@user = User.find(params[:id])
show!
end
end
show do
attributes_table do
row "User" do
link_to @user.display_name, user_path(@user.slug)
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
但是当我加载页面时,我收到一条错误消息:
undefined method `display_name' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
这意味着@user是零.我很肯定@user被正确设置(意味着查找器正在获取数据库中存在的适当数据).我认为它与ActiveAdmin的工作原理有关,我不熟悉.有什么想法吗?
此外,我知道我可以这样做show do |user|,但是我使用它有更复杂的东西,需要访问控制器中的用户对象.
我目前正在制作这样的协会:
show do
h3 project.title
panel "Utilisateurs" do
table_for project.roles do
column "Prenom" do |role|
role.user.firstname
end
column "Nom" do |role|
role.user.lastname
end
column "email" do |role|
role.user.email
end
column "Role" do |role|
role.role_name.name
end
end
end
end
# override default form
form do |f|
f.inputs "Details" do # Project's fields
f.input :title
f.input :code
end
f.has_many :roles do |app_f|
app_f.inputs do
# if object has id we can destroy it
if app_f.object.id
app_f.input :_destroy, :as => :boolean, :label => …Run Code Online (Sandbox Code Playgroud) 我有一个使用mongoid,database_cleaner和rspec的现有项目.我尝试使用可用的active_admin补丁添加active_admin .ActiveAdmin假定它在ActiveRecord项目中,最具体的是通过它对meta_search gem的依赖.
当我去运行我的规格时,它们都会因以下错误而失败:
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::ConnectionNotEstablished:
ActiveRecord::ConnectionNotEstablished
# ./spec/support/database_cleaner.rb:12:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)
相关库的gem版本如下:
测试失败的文件,spec/support/database_cleaner.rb:
require 'database_cleaner'
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
end
config.before(:each) do
DatabaseCleaner.clean
end
end
Run Code Online (Sandbox Code Playgroud) 用户has_many交易.我有活动管理员当前设置为使用belongs_to:user in admin/transactions.rb在用户下嵌套用于基本CRUD的事务.但是,我还需要一个顶级视图,用于显示跨用户的事务记录子集的事务.我怎样才能完成第二部分?
我的指南模型有一个国家/地区属性.我不想使用插件,我只想将国家作为字符串.一切正常,直到我尝试在activeadmin中编辑指南,然后我收到错误消息:
ActionView :: Template :: Error(要使用:country输入,请安装country_select插件,如下所示:https: //github.com/jamesds/country-select):1:insert_tag renderer_for(:edit)
以我的形式,我有
<%= f.input :country, as: :string%>
Run Code Online (Sandbox Code Playgroud)
在我的admin/guidelines.rb中我有
index do
column :title
column :specialty
column :content
column :hospital
column :country
column :user
default_actions
end
Run Code Online (Sandbox Code Playgroud) 我正在使用rails 4 + activeadmin在ruby 1.9.3p392上运行.
当我要去的时候
http://127.0.0.1:3000/admin/login
Run Code Online (Sandbox Code Playgroud)
我得到一个错误:
ActiveAdmin :: Devise :: Sessions#new中的ArgumentError
显示C:/Ruby/lib/ruby/gems/1.9.1/bundler/gems/active_admin-85b9f8164809/app/views/active_admin/devise/sessions/new.html.erb其中第5行引发:
错误的参数数量(3个用于2)
提取的来源(第5行):
<h2><%= title "#{render_or_call_method_or_proc_on(self, active_admin_application.site_title)} #{t('active_admin.devise.login.title')}" %></h2>
<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= active_admin_form_for(resource, :as => resource_name, :url => send(:"#{scope}_session_path"), :html => { :id => "session_new" }) do |f|
f.inputs do
resource.class.authentication_keys.each { |key| f.input key, :input_html => {:autofocus => true}}
f.input :password
Run Code Online (Sandbox Code Playgroud) 我有一个简单的应用程序,它有三个模型Assessment,Question以及AssessmentQuestion
在Assessment我有这样的协会,
class Assessment < ActiveRecord::Base
has_many :assessment_questions, dependent: :destroy
has_many :questions, through: :assessment_questions
end
Run Code Online (Sandbox Code Playgroud)
在Question我有,
class Question < ActiveRecord::Base
has_many :assessment_questions, dependent: :destroy
has_many :bank_questions, dependent: :destroy
end
Run Code Online (Sandbox Code Playgroud)
在AssessmentQuestion我有,
class AssessmentQuestion < ActiveRecord::Base
belongs_to :question
belongs_to :assessment
end
Run Code Online (Sandbox Code Playgroud)
评估问题表有:assessment_id,:question_id和:mark列
我有使用ActiveAdmingem 的管理界面。
在管理界面中创建评估时,在 admin/assessment.rb 我有一个由 formtastic gem 生成的表单,
form do |f|
f.inputs do
f.input :name
f.input :duration
f.input :questions, as: :check_boxes, …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据我在 db 中获得的内容在活动管理员中创建范围。我得到了一个奖励ActiveAdmin::DatabaseHitDuringLoad(在我们使用的 CI 软件中,在本地工作,因为数据库已经加载)
Your file, app/admin/user.rb (line 8), caused a database error while Active Admin was loading. This is most common when your database is missing or doesn't have the latest migrations applied. To prevent this error, move the code to a place where it will only be run when a page is rendered.
我尝试做的是为每个city我在 db 中获得的范围添加一个范围
ActiveAdmin.register User do
City.all.each do |city|
scope city.name, :default => true do |users|
city.users
end
end
end …Run Code Online (Sandbox Code Playgroud) 我在ActiveAdmin中添加了以下过滤器.
filter :roles, as: :select, collection Model::ROLES, multiple: true
Run Code Online (Sandbox Code Playgroud)
但是当我选择过滤器值来搜索角色时.它给了我以下错误
PG::InvalidTextRepresentation: ERROR: malformed array literal: "teacher"LINE 1: ...ted" = $1 AND roles" IN('teacher
DETAIL: Array value must start with "{" or dimension information. ^
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?我们如何使用AA过滤器搜索/过滤ARRAY字段?我正在使用Rails 4.2.4,ruby 2.2.2p95