我正在使用https://github.com/sferik/rails_admin来处理我的管理界面.
可以根据此模型中存在的当前列(id,created_at等)过滤模型.
我希望能够为关联添加自定义过滤器.
例如:
当我在探索"城镇"模型时,我希望能够只显示有一个或多个项目的城镇.
我可以通过向城镇添加一个新列来实现这一点,将has_projects称为布尔值,当有一个或多个项目关联时,它将设置为true,但我觉得必须有一种更清晰的方法来制作自己的自定义过滤器?
我有两个使用Devise的User和Admin(使用RailsAdmin)模型.我以用户身份登录,然后以管理员身份登录.但从其中一个模型退出的结果是同时退出两个模型.我该如何解决?请帮忙 :)
我正在使用rails_admin和globalize3,并且无法使可搜索的关联工作.以下是模型(Person has_one/belongs_to Name has_many/belongs_to NameTranslation):
class Person < ActiveRecord::Base
  has_one :name, inverse_of: :person
end
class Name < ActiveRecord::Base
  belongs_to :person, inverse_of: :name
  translates :first_name, :last_name
  has_many :name_translations, inverse_of: :name, dependent: :destroy
end
class NameTranslation < ActiveRecord::Base
  belongs_to :name, inverse_of: :name_translations      
end
该NameTranslation模型来自globalize3,它包含与name(first_name和last_name)plus locale和name_id,相同的属性.
在config/initializers/rails_admin.rb我有
config.model Person do
  list do
    field :name do
      searchable name_translations: :last_name
    end
  end
end
然后,在GUI中,当我添加过滤器时name,我得到:
SQLite3::SQLException: no such column: name_translations.last_name: SELECT  "people".* FROM …在rails admin中,您可以为模型及其子项定义导航标签,如下所示:
# in rails_admin.rb
config.model Order do
  navigation_label 'Orders related'
end
config.model OrderProducts do
  parent Order
end
有没有办法在不创建模型的情况下向导航菜单添加标签(即仅用于分组)?
我在我的应用程序中使用rails_admin.我的模型上有一些范围,下面是一个例子:
class User < ActiveRecord::Base
  scope :unconfirmed, where('confirmed_at IS NULL')
end
在rails_admin中是否可以作为过滤器访问这些范围?就像你可以在主动管理员.就像在用户部分的某处添加按钮一样.
谢谢
我正在玩Rails管理员,我注意到了一些事情.
在模型中定义如下的属性,在Rails管理员中计为"必需"
 validates :user, presence: true
但是,表(模式/迁移)中定义的属性仍被视为"可选"
t.datetime "created_at",:null => false
我会假设这两个都是相同的,除了可能出现验证错误的级别.我错了还是Rails管理员错误?这两者是否确保成功保存现场所需的字段或存在差异?
我想将Google Analytics嵌入式API中的JS添加到我的rails应用程序中,仅用于Rails管理员(其他地方不需要).
我们已经覆盖了Rails Admin Dashboard,现在我们正在努力使用自定义JS.
我在这里找到了:https://groups.google.com/forum/#!topic/rails_admin/KgUl3gF5kTg,它需要放入app/assets/javascripts/rails_admin/custom/ui.js.
所以我将所有.js文件和.js.map文件放在目录中:
.
??? custom
    ??? active-users.js
    ??? chart.js
    ??? datepicker.js
    ??? moment.js
    ??? platform.js
    ??? platform.js.map
    ??? polymer.js
    ??? polymer.js.map
    ??? promise.js
    ??? ui.js
    ??? viewpicker.js
我已经//= require_tree .在ui.js文件中添加但在rails_admin中我仍然收到:
Uncaught ReferenceError: Polymer is not defined 
这意味着未加载.JS文件.
感谢此链接以查找上述链接:Rails管理员:将javascript库添加到自定义操作
编辑1:在Rails 3环境中使用Rails Admin.
编辑2:
因此,出于测试原因,我删除了所有自定义JS/HTML等.
我在ui.js中设置了这个:
//=require_tree .
我在leecher.js中设置了这个:
$(document).ready(function() { document.MY_SIMPLE_VARIABLE = 2; } );
当我重新启动服务器时,我转到rails admin,注销,重新启动服务器,登录.转到chrome中的控制台并键入:
document.MY_SIMPLE_VARIABLE
我收到以下内容:

出于测试原因,我添加了一个:
alert("hello world");
但仍然没有触发器.
ui.js和leecher.js的位置是: …
我有一个模型,我想隐藏在rails_admin左侧的导航,但它不起作用.(我仍然想要访问它,只是想从面板中隐藏它,所以排除不计算)
我已经尝试了下面的所有三种代码,但它不起作用:
config.model 'Document' do
 visible false
end
从这里:https://github.com/sferik/rails_admin/wiki/Navigation
以及代码:
config.model 'Document' do
   hide_from_navigation
end
从这里:http://www.verious.com/code/foca/rails_admin/
以及代码:
config.model 'Document' do
   navigation do
      visible = false
     end
end
有人能为我解释原因吗?
我在检查之前已经重新启动了服务器.
谢谢!
我使用的是rails_admin和paperclip,但是使用带有回形针属性的模型安装rails_admin has_attached_file会引发错误
undefined method `attachment_definitions'
我在主git分支和受保护的属性gem中使用Rails 4和rails_admin.
使用Rails管理员和Dragonfly.但是,当我创建了一个新帖子,附件连接:ob到dragonfly并想要编辑它.这是"没有选择文件".因为它没有拿起已存在的文件?
在我的rails_admin中,我做到了这一点.
edit do
  field :name
  field :information
  field :ob, :dragonfly
  field :document_categories
end
这是我的模特:
class Document < ActiveRecord::Base
  has_and_belongs_to_many :document_categories
  after_commit :generate_versions, on: :create
  dragonfly_accessor :ob
  validates :name, :ob, presence: true
  def generate_versions
    DocumentWorker.perform_async(self.id)
  end
  def convertable_image?
    unless self.try(:ob).nil?
      self.try(:ob).mime_type.include?("image") || self.try(:ob).mime_type.include?("pdf")
    else
      return false
    end
  end
  def respond_with_type
    case self.try(:ob).mime_type.split("/")[1]
      when "vnd.ms-powerpoint" , "vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.template"
        "powerpoint"
      when "application/vnd.ms-excel" , "vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        "excel"       
      when "application/msword" , "vnd.openxmlformats-officedocument.wordprocessingml.document"
        "word"                
      else
        self.try(:ob).mime_type.split("/")[1]
      end
  end  
  default_scope{order("name ASC")} …