Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/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 3 属于协会和formtastic_Ruby On Rails 3_Formtastic_Belongs To - Fatal编程技术网

Ruby on rails 3 属于协会和formtastic

Ruby on rails 3 属于协会和formtastic,ruby-on-rails-3,formtastic,belongs-to,Ruby On Rails 3,Formtastic,Belongs To,我有一个模型产品,它与另一个模型类型有关联。在产品的表单中,我使用formtastic显示一个select标记,其中包含数据库中可用的所有类型,如下所示: <%= f.input :type %> 有什么想法吗?试试member\u label选项,听起来像是你想要做的: <%= f.input :type, :member_label => :title %> :title%> 示例更多。只需将其添加到您的模型中即可 def name retu

我有一个模型产品,它与另一个模型类型有关联。在产品的表单中,我使用formtastic显示一个select标记,其中包含数据库中可用的所有类型,如下所示:

<%= f.input :type %> 

有什么想法吗?

试试
member\u label
选项,听起来像是你想要做的:

<%= f.input :type, :member_label => :title %>
:title%>

示例更多。

只需将其添加到您的模型中即可

  def name
    return self.title
  end
<%= f.input :type, :member_label => :title %>
  def name
    return self.title
  end