Leonel - wrote:
And why not use Haml?
I don’t know what that is
But you know what Google is, right?
Look it up!
haha, thanks, already did. HAML sounds good
Where in the controller are you setting the variable? Let’s see the
entire controller method that you’re using.
I was setting it at the top of the controller, thinking it would
propagate to all the methods.
class ServicesController < ApplicationController
@durations = {“30 minutes” => “30”, “1 hour” => “60”, “1 hour 30
minutes” => “90”, “2 hours” => “120”}
Yeah, I thought you might be doing that. That won’t work.
The problem is that @instance_variables are always instance variables of
self. Inside an instance method (and controller actions are instance
methods), self is an instance of ServicesController.
Outside an instance method, however, self is the class object itself!
(That is, self is the object called ServicesController, which is an
instance of class Class). Thus, you’re setting the instance variable on
the wrong object.
def index
@services = Service.all
…
end
But then I moved it inside the method.
def new
@service = Service.new
@durations = {“30 minutes” => “30”, “1 hour” => “60”, “1 hour 30
minutes” => “90”, “2 hours” => “120”}
…
It gave me another descriptive error message that led me to fix the form
partial.
<%= f.label :duration %>
<%= f.select ("duration", @durations, :prompt => "Select") %>
And it works now! XD
Exactly! You’re defining the variable in the right place, so it’s
getting copied to the view.
Sorry, I know this is probably very basic but I just started yesterday
my first Rails application outside of a tutorial book.
Congrаtulations and good luck! Remember to do all development
test-first (I recommend RSpec, Cucumber, and Machinist for this), and
set up version control (preferably Git) if you haven’t done so already.
Thanks for pointing me in the right direction! 
You’re welcome.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]