Question

In rails 4.0.0.

Why does this work

@employees = Employee.where(:club_id => session[:club_id]).page(params[:page])

but not this?

@payments = Payment.where(:club_id => session[:club_id], 
                           :trading_date => trading_date).page(params[:page])

On the second form I get an array error. I know how to fix it but I am perplexed as to why this occurs?

my error is this

NoMethodError (undefined method `page' for #<Array:0x007ff72845b380>):
app/controllers/payments_controller.rb:30:in `index'
Was it helpful?

Solution

Are you sure you dont want to do

@payments = Payment.where(:club_id => session[:club_id])
  .where(:trading_date => trading_date)
  .page(params[:page])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top