1

I have this in my form:

<%= f.select :status, options_for_select(Article::STATUS), :include_blank => true, :selected => @article.status, :class => 'select_field' %>

Model:

class Article < ActiveRecord::Base
  attr_accessible :author, :content, :publication_date, :status, :title, :tag_tokens
  attr_reader :tag_tokens

  STATUS = ['Rascunho', 'Em Revisão', 'Publicado']

end

Why does not populate the field?

4

1 回答 1

3

我相信您可以简单地将数组传入[#select][1]. 您不需要调用选项来收集。如果这是一个模型表单,我也认为你可以省略该:selected选项,Rails 将使用属性值来计算它。

尝试这个:

<%= f.select :status, Article::STATUS, :include_blank => true, :class => 'select_field' %>
于 2012-07-30T11:32:12.223 回答