Hey folks,
I’m having major issues trying to complete a simple task.
Goal:
Create a drop-down list and populate it with states. When the user
fills out the form and saves, the state selected should be saved with
the record.
Problem:
When trying to save the record I get the following error:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.inject
And it points to this line in my .rthml:
<%= select_tag ‘state’, options_for_select(@states) %>
And here is my controller code in the ‘new’ method:
def new
@client = Client.new
@states = %w{-select- AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN
IA KS KY
LA ME MH MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND
OH OK
OR PA RI SC SD TN TX UT VT VI VA WA WV WI WY}
end
The list populates fine with states, but bombs when I try to save.
Please help.
Thanks.