Active Record Rails 3.2 undefined method 'each'

am running ruby 1.9.2 and rails 3.2. I have active record call that is
returning nil even though the data is there. So my question is, what
part
am I missing to return the records?

my model is:stores.rb

class Stores < ActiveRecord::Base

establish_connection “as400_#{RAILS_ENV}”
set_table_name “SIGNCUSTM2”

def self.find_stores(params)Customer.where(“CAD505=? AND TRYT20=?”,
params[:parmstate], params[:parmrep]).where.not(cusn05: nil)end

def index
    @customers = Customer.find_stores(params[:model])
end

end

my view: store.html

        <% @customers |customer| %>

        <p align="center">

            <strong>Store:</strong>&nbsp;<%= select_tag :customers 

%>

On 7 February 2014 21:24, Bob K. [email protected] wrote:

am running ruby 1.9.2 and rails 3.2. I have active record call that is
returning nil even though the data is there. So my question is, what part am
I missing to return the records?

Look in development.log where you should find the sql generated.
Looking to see what is wrong with that should give you a clue.

Colin

On Friday, February 7, 2014 9:24:43 PM UTC, Bob K. wrote:

am running ruby 1.9.2 and rails 3.2. I have active record call that is
returning nil even though the data is there. So my question is, what part
am I missing to return the records?

There are a few weird things in your code:
def self.find_stores(params)

Customer.where(“CAD505=? AND TRYT20=?”, params[:parmstate],
params[:parmrep]).where.not(cusn05: nil)end

Using .not like that is a rails 4 thing but you’ve said you’re using rails
3.2

my view: store.html

        <% @customers |customer| %>

I’m surprised that doesn’t cause a syntax error.

What is it that is nil? even if your conditions were incorrect, the code
you posted would return an empty relation/array rather than nil

Fred