【发布时间】:2013-05-01 21:11:14
【问题描述】:
我刚刚为我的电影表构建了一个名为 year_id 的迁移 当我创建两个新年份,2012 年和 2013 年时,然后添加下拉列表以选择年份 我明白了:
如何让我的下拉选择显示实际年份(2012 年或 2013 年)而不是 #
这是我的模型:
class Year < ActiveRecord::Base
attr_accessible :year
has_many :movies
end
这是我的表格:
<%= semantic_form_for @movie, :html => { :multipart => true } do |f| %>
<% if @movie.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@movie.errors.count, "error") %> prohibited this movie from being saved:
</h2>
<ul>
<% @movie.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field"> <%=h f.input :year, :include_blank => false %> </div><br />
【问题讨论】:
-
你能把你的 Year 模型的内容贴出来吗?谢谢
-
类年
-
请分享选择的代码,基本上你得到的是对象而不是
year属性。 -
这是形式 { :multipart => true } do |f| %>
禁止保存这部电影:
false %>
-
@ 符号通常没有间隔,但 stackoverflow 不允许,因此为此进行了更改
标签: ruby-on-rails forms migration semantics