Marnen Laibow-Koser wrote:
> Why not just use collection_select?
According to
http://shiningthrough.co.uk/Select-helper-methods-in-Ruby-on-Rails "Use
select when you require a basic drop-down selection box populated with
data not sourced from a database"
> And why not use Haml?
I don't know what that is
> Of course you did! The view has no access to model instance variables.
> If you want to use @durations in the view, you'll need to set it in the
> *controller*, not the model. Rails copies controller instance variables
> to the view.
I just tried it from the controller and gives me same error message.
CONTROLLER
@durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30
minutes" => "90", "2 hours" => "120"}
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
Extracted source (around line #20):
17: </div>
18: <div class="field">
19: <%= f.label :duration %><br />
20: <%= f.select ("duration", @durations.map {|d| [d.id, d.name]},
:prompt => "Select") %>
21: </div>
22: <div class="field">
23: <%= f.label :cost %><br />
> No such thing as an "instance hash". Did you mean an instance variable
> that happens to contain a Hash?
Haha, yes, sorry, that's what I meant
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.