Tag: activeadmin

活动管理员:同一列中的多个操作类似于查看,编辑,删除

我正在使用活动的admin gem来为我的ruby on rails应用程序提供管理控制台。 我有一个问题,我希望对索引页面上的每个项目进行多个自定义操作,就像查看,编辑,删除一样。 但是在添加自定义操作时,仅显示最后一个而不是全部。 index do column ‘Instructor Name’,:user column ‘Email Address’, :email column ‘Phone Number’, :phone column ‘website’, link_to ‘google’, ‘www.google.com’ column :bio actions defaults: false do |application| if application.user.instructor == 2 button_to ‘Disapprove’, instructor_deny_user_path(application.user.id), method: :put else button_to ‘Approve’, instructor_approve_user_path(application.user.id), method: :put end link_to “resume”,getresume_instructor_applications_path(id: application.id) end end 仅显示恢复链接,而不是批准/反驳和恢复 我究竟做错了什么

安装Active Admin并获取ArgumentError

我正在尝试第一次使用ActiveAdmin w / Rails 4.安装所有相关gem后,我尝试运行安装程序,即: rails generate active_admin:install 这样做会给我以下错误: in `add_route’: Invalid route name, already in use: ‘admin_root’ (ArgumentError) 但是,我在routes.rb中没有任何’admin_root’路由,所以我有点困惑。 这是运行’rake routes’的输出: Prefix Verb URI Pattern Controller#Action exams GET /exams(.:format) exams#index POST /exams(.:format) exams#create new_exam GET /exams/new(.:format) exams#new edit_exam GET /exams/:id/edit(.:format) exams#edit exam GET /exams/:id(.:format) exams#show PATCH /exams/:id(.:format) exams#update PUT /exams/:id(.:format) exams#update DELETE /exams/:id(.:format) exams#destroy […]

无法登录ActiveAdmin

我遇到登录ActiveAdmin的问题。 使用无法登录Active Admin的解决方案。 有没有办法创建管理员用户? 并且无法登录Active Admin , 我尝试在rails console运行以下命令 user = AdminUser.new user.email = ‘abc@example.com’ user.password = ‘new_password’ user.save 在user.save ,它给我以下消息: (0.0ms) begin transaction AdminUser Exists (0.0ms) SELECT 1 AS one FROM “admin_users” WHERE “admin_users”.”email” = ‘abc@example.com’ LIMIT 1 false (1.0ms) rollback transaction 据我了解,这未能创造记录,对吗? 我也尝试了以下解决方案: AdminUser.create :email => ‘abc1@example.com’, :password => ‘password’, :password_confirmation => ‘password’ […]

使用Rails 3.1应用程序更改活动管理员中下拉关联filter中显示的属性

我在我的Rails应用程序中使用Active Admin gem,在我的一个模型管理页面上,有一个用于与另一个模型关联的filter。 下拉菜单显示#而不是相应的属性。 例如,如果我的模型是属于用户的post,则在post管理员索引页面上会有一个用户filter,在该filter的下拉菜单中将是id,例如# 。 我希望能够在此filter的下拉菜单中显示适当的内容。 如何使用Active Admin执行此操作? UPDATE 正如ciastek在答案中所指出的,这与这个问题非常相似,事实上,我也使用“company_name”作为属性而不是“name”

如何将filter添加到Active Admin仪表板?

我想在Active Admin Dashboard页面上为我的几个模型添加搜索function。 我怎么做? 对于常规模型,我可以使用“filter”,但我如何在仪表板视图上执行此操作。 部分和ActiveAdmin :: Dashboards.build中可用的方法有哪些?

如何在覆盖控制器后显示activeadmin表单中的错误

我有一种情况需要覆盖activeadmin中的create。 我自动填充字段,如果数据已经存在,则应更新否则创建。 这是我的创建方法: def create id = params[:company].dig(:id) if id.present? @company = Company.find(id) if @company.update(permitted_params[:company]) redirect_to resource_url flash[:notice] = ‘Company created successfully’ else #add errors to semantic errors end else new_permitted_params = permitted_params[:company].except(:id) @company = Company.new(new_permitted_params) @company.save if @company.errors.any? #add this to semantic errors so that activeadmin handles and displays the errors end end end […]

活动管理员排序has_many列的计数

使用Active Admin框架,我可以添加一个“用户”列,通过执行以下操作来总计特定“俱乐部”的计数: ActiveAdmin.register Club do index do column ‘Users’ do |club| club.users.count end end end 我可以以某种方式对此进行排序吗?

Rails Active Admin如何使用2列config.sort_order(关联中的1列)

在Active Admin中想知道如何设置带有2列的config.sort_order,其中第一列来自同一模型,第二列来自关联模型? ActiveAdmin.register Race do menu parent: :races, :label => proc{ I18n.t(‘activerecord.models.races’) } belongs_to :meeting, :optional => true #need to order by “meetings.date desc races.time desc” config.sort_order = “?” controller do def scoped_collection end_of_association_chain.includes(:meeting) end end end

has_and_belongs_to_many关系的自定义活动管理表单输入

我有一个非常简单的模型 class Lifestyle < ActiveRecord::Base attr_accessible :name has_and_belongs_to_many :profiles end 与Profile有has_and_belongs_to_many关系 class Profile < ActiveRecord::Base attr_accessible … belongs_to :occupation has_and_belongs_to_many :lifestyles accepts_nested_attributes_for :lifestyles end 我想使用ActiveAdmin编辑Profile对象,但也将Lifestyles分配给配置文件。 它应该类似于处理belongs_to :occupation Occup,因为它由ActiveAdmin自动整理到一个预先填充了可用职业的选项的dropbox。 我曾尝试使用has_many表单构建器方法,但这只是让我显示一个表单来输入生活方式的名称,并在提交时,它返回了一个错误。 f.object.lifestyles.build f.has_many :lifestyles do |l| l.input :name end 我得到的错误: Can’t mass-assign protected attributes: lifestyles_attributes 对我来说,最好的方法是构建几个复选框 ,一个用于DB中的每个Lifestyle。 选择表示生活方式连接到配置文件,未选择意味着删除关系。 我非常怀疑使用ActiveAdmin可以实现这一点,并且无需创建非常复杂的逻辑来处理这个问题。 如果你提出你的意见并告诉我是否应该采用这种方式或采用不同的方法,我将非常感激。

修改rails ActiveAdmin gem中的BaseController

我在rails应用程序中使用ActiveAdmin gem。 如果我想在适用于所有activeadmin gems的filter之前添加一个新的filter,我该怎么做? 我想我可以在ActiveAdmin中修改BaseController来实现这一点,但是在rails应用程序中进行这种修改的正确方法是什么? 有没有办法复制和覆盖BaseController?