Rails simple_form association

泄露秘密 提交于 2019-12-03 16:20:08

looks like Organization model doesn't have any of these fields: [ :to_label, :name, :title, :to_s ] so SimpleForm can't detect a default label and value methods for collection. I think you should pass it manually.

John

add to_label function to your Organization class as shown below

class Organization < ActiveRecord::Base
  has_many :members
  attr_accessible :organization_name

  def to_label
    "#{organization_name}"

  end
end

refered Simple form association custom label name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!