Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用rails\u admin在“属于”关联上显示下拉列表_Ruby On Rails_Associations_Model Associations_Rails Admin - Fatal编程技术网

Ruby on rails 使用rails\u admin在“属于”关联上显示下拉列表

Ruby on rails 使用rails\u admin在“属于”关联上显示下拉列表,ruby-on-rails,associations,model-associations,rails-admin,Ruby On Rails,Associations,Model Associations,Rails Admin,我正在使用rails\u admin来管理rails应用程序中的数据 我有这门课: class Activity < ActiveRecord::Base attr_accessible :content, :title, :category_id belongs_to :category, :inverse_of => :activities end 现在,它以如下形式呈现类别: config.model Activity do edit do field :

我正在使用
rails\u admin
来管理rails应用程序中的数据

我有这门课:

class Activity < ActiveRecord::Base
  attr_accessible :content, :title, :category_id
  belongs_to :category, :inverse_of => :activities
end
现在,它以如下形式呈现类别:

config.model Activity do
  edit do
    field :title
    field :content, :text do
      bootstrap_wysihtml5 true
    end
    field :category
  end
end


它应该呈现类别的名称,对吗?我错过了什么?

我已经找了好一阵子了。要获得一个非常好的自动完成下拉列表,只需添加:

config.model Activity do
  edit do
    field :category, :belongs_to_association
  end
end

它看起来应该可以工作,当前是否定义了明确的类别,即不是空白?我尝试了类似的“属于”关联,关联的记录仍然显示为Station#1 Station#2。有什么想法吗?我希望显示实际的桩号名称,而不是对象。
config.model Activity do
  edit do
    field :category, :belongs_to_association
  end
end