Hi Colin, I don't think it is, in fact I know it isn't empty because the logic is inside a test for the return size of 0.
if @my_names.size == 0 render :update do |page| // Bunch of updating code to the displayed message to indicate no match found. page[:name].visualEffect('highlight') end else // This is where I try to test the code of if @my_names[0].province == "XX" // Then want to do some other things. else // Set sessions variables. session[:var_a] = @my_names session[:var_b] = @my_names[0].first_name session[:var_c] = @my_names[0].last_name session[:var_d] = @my_names[0].line_1 session[:var_d] = (@my_names[0].line_2 || '') session[:var_e] = (@my_names[0].province || '') ---------- Any thoughts ? It doesn't seem to matter if I test AFTER the initial test for 0 or before (knowing that I am going to get a match because of predefined values that exist in the database.) I always get the same error. Thanks again in advance. Colin Law wrote in post #1083465: > On 7 November 2012 22:06, Jeff Lockyer <li...@ruby-forum.com> wrote: >> NoMethodError (undefined method `province' for nil:NilClass): >> /path/file.rb:302:in `set_no' >> >> So I look on that line, in the set_no definition, which is where I was >> trying to call this line >> >> if @my_names[0].province == "XX" > > As I said, the clue is in the error message. Undefined method > province for nil:NilClass. This is saying that you have tried to call > the method province on a nil object, which means that @my_names[0] is > nil. > > Colin -- 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 rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.