I can’t see the difference in the ruby console between Model.all and Model.where(:source_id => 2). My problem is with the «all» instruction I can do .each on the array and with Model.where I can’t do .each
Working
# controller.rb
@results = Adress.all
#view.haml
- @results.each do |result|
Not-Working
# controller.rb
@results = Adress.where(:source_id => 2)
#view.haml
- @results.each do |result|
Error message –> undefined method `each’ for nil:NilClass
In console –> Adress.where(:source_id => 2) it’s works
——- MY BAD, THE SOLUTION ——
my view was trying to do .each on inexistent variable…….
THE PROBLEM
@Adress = Adress.where(:arrondissement_id => params[:arrondissement])
THE SOLUTION
@results = Adress.where(:arrondissement_id => params[:arrondissement])
My bad,
my view was trying to do .each on inexisting.
THE PROBLEM
THE SOLUTION