select include_blank alternative

I'm trying to create a list of options with the top item returning ""
while displaying none

<%= select (:activity, :location_state, [["None",""]]+
@client.location_addresses.map {|location|
[location.state,location.state]}.uniq.sort, {:selected =>
@location_state_selected }) %>

This generates what I would think would be the right option tags (and
they look right in show source as well) but when it's returned to the
server :location_state => "None" insead of ""

What gives? Any ideas?

Thanks,
-dustin

Hi. Try write [["", "None"]]
first - value, second - the displaying string.

Another way - using parameter :prompt => "None", in your case:

<%= select (:activity, :location_state,
@client.location_address.map{|location| [location.state,
location.state]}.uniq.sort, {:prompt => "None"}, {:selected =>
@location_state_selected}) %>

Best Regards, Sergey

Hmm I figured out where the problem is coming from. I'm using
observe_form to watch for changes in this form. The params that are
getting to the :url in observe_form are wrong. I've written a simple
test case:

Two rhtml files will show what I'm talking about:

params_test.rhtml:
<html>
<head>

  <title>params</title>
  <%= javascript_include_tag "prototype" %>

</head>

<body>
<%= form_tag ({:action => "render_params"}, {:id => 'form'}) %>
<%= select (:activity, :location_type, [["Store","0"], ["DC", "1"]],
{:prompt => "None"}) %>
<%= submit_tag %>

<%= observe_form(:form,
         :update => 'params',
         :url => {:action => 'render_params'}) %>
<div id='params'></div>
</body>
</html>

render_params:
<html>
<head>

  <title>render_params</title>

</head>

<body>

params:<br/>
<%= debug(params) %>
request.params:<br/>
<%= debug(request.params) %>

</body>
</html>

Now if I submit the form render_params returns:
params:
--- !map:HashWithIndifferentAccess
commit: Save changes
activity: !map:HashWithIndifferentAccess
  location_type: ""
action: render_params
controller: params_test
request.params:

Weird it was a bug with the prototype library that shipped with Rails
on Locomotive. I updated my prototype.js file (which is smaller than
the one that was in public/javascripts/) and it started working.
Should I report a bug somewhere to someone (Locomotive?)

-dustin