I am sending this information:
<%= observe_field "resource_focus_id",
:frequency => 0.25,
:url => { :action => :add_sub_focus},
:with => "'focus_id='+ value +
‘&sf_id=#{@resource.sub_focus_id}’",
:update => "resource_sub_focus_id" %>
Which turns out to be:
All is good. Now in my controller I have:
def add_sub_focus
@sub_focuses = SubFocus.find_all_by_focus_id(@params[“focus_id”])
@sf_id = @params[“sf_id”]
end
My add_sub_focus.rhtml file:
<% for sub_focus in @sub_focuses do -%>
<% if #{sub_focus.id} != #{sf_id} %>
<option value="<%= sub_focus.id %>">
<%= sub_focus.name %>
</option>
<% else %>
<option value="<%= sub_focus.id %>" selected="selected">
<%= sub_focus.name %>
</option>
<% end %>
<% end -%>
Why does the option with the value of “2” not get selected? I know for
sure that that value is present.
If I do this:
<% for sub_focus in @sub_focuses do -%>
<% if #{sub_focus.id} == #{sf_id} %>
<option value="<%= sub_focus.id %>" selected="selected">
<%= sub_focus.name %>
</option>
<% else %>
<option value="<%= sub_focus.id %>">
<%= sub_focus.name %>
</option>
<% end %>
<% end -%>
I think every option gets selected because the last option is display
(as selected) and that isn’t the value that should be selected.
Thanks.
Seth