mar*_*ion 4 ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1
我有一个collection_select:
<%= form_for(@feedback) do |f| %>
<div class="field">
<%= f.label :poster_id %><br />
<%= f.collection_select :feedback, :poster_id, @users, :id, @user.username, :prompt => "Select your username" %><br />
<%= f.number_field :poster_id %>
</div>
<% end %>
这是错误消息:
ActionView::Template::Error (undefined method `merge' for "test":String):
    15:     
    16:   <div class="field">
    17:     <%= f.label :poster_id %><br />
    18:     <%= f.collection_select :feedback, :poster_id, @users, :id, @user.username %><br />
    19:     <%= f.number_field :poster_id %>
    20:   </div>
    21:   <div class="field">
  app/views/feedbacks/_form.html.erb:18:in `block in _app_views_feedbacks__form_html_erb__3181571289116259961_2154876620'
  app/views/feedbacks/_form.html.erb:3:in `_app_views_feedbacks__form_html_erb__3181571289116259961_2154876620'
"test"是返回的用户名@user.username.
我该如何解决这个问题?
Mar*_*sen 11
collection_select的签名是:
def collection_select method, collection, value_method, text_method, options = {}, html_options = {}
我不确定你要做什么,也许这就是你想要的:
<%= f.collection_select :poster_id, @users, :id, :username, :prompt => "Select your username" %><br />