Leonel *-* wrote:
> CONTROLLER
>   @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
> minutes" => "90", "2 hours" => "120"}

Where did you put this line? You're not showing any context.

> 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 />

Which template file is this from? Guessing it's in the the context of an 
edit.html.erb or new.html.erb.

Also guessing that you probably need to have that hash available to both 
the edit and new pages so you will probably need to set @durations using 
a before_filter:

before_filter load_durations, :only => [ :new, :edit ]

private
def load_durations
@durations = { "30 minutes" => "30",
               "1 hour" => "60",
               "1 hour 30 minutes" => "90",
               "2 hours" => "120" }
end
-- 
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.

Reply via email to