@templates_array.each do |i|
templateOptions = templateOptions + "<option
value=#{i}>#{i}"
end
each does not deal gracefully with emtpy arrays or nil. So change to
if @templates_array @templates_array.each do |i|
templateOptions = templateOptions + “#{i}”
end
end
or
@templates_array.each do |i|
templateOptions = templateOptions + “#{i}”
end if @templates_array
That last line may need to be
end unless @templates_array.nil?
HTH,
Jeffrey
Thank you very much for your help Jeffrey.
I tried this code in another application, it worked. I don t know why
here given this error. there are four files in the folder. the path is
right the codes also look right however that I have error.
I can not add another option and value either.
@templates_array.each do |i|
templateOptions = templateOptions + "<option
value=#{i}>#{i}"
end
each does not deal gracefully with emtpy arrays or nil. So change to
if @templates_array @templates_array.each do |i|
templateOptions = templateOptions + “#{i}”
end
end
or
@templates_array.each do |i|
templateOptions = templateOptions + “#{i}”
end if @templates_array
That last line may need to be
end unless @templates_array.nil?
HTH,
Jeffrey
Thank you very much for your help Jeffrey.
I tried this code in another application, it worked. I don t know why
here given this error. there are four files in the folder. the path is
right the codes also look right however that I have error.
I can not add another option and value either.
OK I found the problem… I defined the @templates_array in the wrong
method.
that s why program could n t get array.
thank you very much Jeffrey
actually you can still give me idea about how to add new option and
value. I still couldnt add it. when I add new option it creates 4 of
them.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.