【问题标题】:Rails admin hide buttons in has_many nested formRails 管理员以 has_many 嵌套形式隐藏按钮
【发布时间】:2016-02-12 18:26:25
【问题描述】:

我正在使用 Rails 管理员。我有三个模型:

class Tag < ActiveRecord::Base
    has_many :tags_users, :dependent => :destroy  
end

class TagsUser < ActiveRecord::Base
    belongs_to :user_spot, :inverse_of => :tags_users
    belongs_to :tag
end

class UserSpot < ActiveRecord::Base
    has_many :tags_users, :inverse_of => :user_spot
    accepts_nested_attributes_for :tags_users, :allow_destroy => true
end

以及正在显示的内容:

我想隐藏“添加新标签”和“编辑此标签”按钮。我怎么能这样做?

【问题讨论】:

    标签: ruby-on-rails ruby has-many rails-admin belongs-to


    【解决方案1】:

    试试

    field :tag do 
      inline_add false
      inline_edit false
    end
    

    【讨论】:

    • 我在初始化程序/rails_admin.rb 的 config.model TagsUser 中添加了它,并且它起作用了。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2012-11-10
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 2020-12-13
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多