Correct value doesn't get selected in select

Hi,

I’ve got a Form with a select helper, but the value in the database
doesn’t get selected:
The name of the model is “special_tip” and belongs to a
special_quest_option and a special_quest

<% form_for special_tip do |f|%>
<%= select(“special_tip”, “special_quest_option_id”,
special_quest.special_quest_options.all.collect {|sqo| [ sqo.text,
sqo.id ] },{:include_blank => true}) %>
<%= f.submit “tip the Special Quest” %>
<% end %>

What do I’m doing wrong?
The correct values are in the select box, but the current doesn’t get
selected.
Thanks

On 1 Mar 2010, at 16:05, LeonS wrote:

sqo.id ] },{:include_blank => true}) %>
<%= f.submit “tip the Special Quest” %>
<% end %>

What do I’m doing wrong?
The correct values are in the select box, but the current doesn’t get
selected.

You’re mixing form_for (which doesn’t require that you have an instance
variable containing the object) and the non form builder version of
select (which does).

f.select(“special_quest_option_id”, …)

should work better

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs