I saw a post for a select tag, in the options_for_select([["value 1",
"1"], ["value 2", "2"], "3", "4"],["1", "3"]) works fine.
If I do @test_select = [["value 1", "1"],["value 2", "2"], "3", "4"],
["1", "3"] in the controller
I try to do options_for_select(@test_select) in the place I get a NIL
value. Any reason why the array is not getting to the view??
the array should consist of two element arrays,
one element is the key, the other the value.
Don't see, what you want to do with this strange
mix of values and arrays here.
You're probably not quite doing what you think you are. Post some code.
As a random shot in the dark, if you are calling render explicitly then you must set @test_select before you do this.
Fred
In the controller I have @test_select = [['New Install','1'],['NIU
LOOP','2'],['CSU LOOP','3'],['NIU_CSU LOOP','4'],['Maintenance','5']]
In the view I have <%= select('test_method', 'id', @test_select,
{:prompt => 'Select Test Method' } )%>
Why is it telling me there is a NIL value where the variable
@test_select is?
I am not sure how to get it to give me a select list.
In the controller I have @test_select = [['New Install','1'],['NIU
LOOP','2'],['CSU LOOP','3'],['NIU_CSU LOOP','4'],['Maintenance','5']]
In the view I have <%= select('test_method', 'id', @test_select,
{:prompt => 'Select Test Method' } )%>
Why is it telling me there is a NIL value where the variable
@test_select is?
post all your code, not just the snippets. eg what line is raising an
exception and what is the stack trace?
Fred
This is the View 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.inject
Extracted source (around line #13):
10:
11: <p>
12: <div id="time1" style="display: inline">T-1 #1 <%=
text_field :circuit1, :name, :size => '15', :value => "Circuit
ID", :onfocus => "if (this.value == 'Circuit ID') {this.value =
'';}",:onblur => "if (this.value == '') {this.value = 'Circuit ID';}" -
%>
13: <%= select('test_method', 'id', @test_select, {:prompt =>
'Select Test Method' } )%>
14: <%= text_field :time1, :time, :size => '5', :value =>
"Time", :onfocus => "if (this.value == 'Time') {this.value =
'';}",:onblur => "if (this.value == '') {this.value = 'Time';}" -%>
15: <%= submit_to_remote 'commit1', "Test Circuit",:onclick => "new
Element.show('save')",
16: :url => { :action => 'diagnose_circuit' },
RAILS_ROOT: F:/BACKUP/Backup/Web_apps_svn_working/CircuitDiagnosis
Application Trace | Framework Trace | Full Trace
This is the View 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.inject
stack trace sure would be useful...
What's in the controller ?
Fred
Doh. Fixed it. Had the stinking Instance var in the wrong place in
the controller.