I'm trying to display a drop-down menu by using an instance variable
from a model.

THIS WORKS...

<div class="field">
  <%= f.label :duration %><br />
  <%= f.select ("duration", {"30 minutes" => "30", "1 hour" => "60"},
:prompt => "Select") %>
</div>

THIS DOESN'T WORK...

Now, I want to populate the values from the model like this
@durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30
minutes" => "90", "2 hours" => "120"}

Then in the form partial I have this
<div class="field">
  <%= f.label :duration %><br />
  <%= f.select ("duration", @durations.map {|d| [d.id, d.name]}, :prompt
=> "Select") %>
</div>

I get this error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map

How can I initialize an instance variable or instance hash and then use
it on the form for the drop-down menu?
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to