What is wrong with this statement
@lastloc = Location.all(:customer_id == resource.id , :order => 'created_at DESC').first
if (@lastloc.longitude != params[:customer][:longitude] && @lastloc.latitude != params[:customer][:latitude])
...
end
What i am trying to do is to grab all Location with a certain id, then order then with the latest one then verify if different value then i proceed else do nothing
You can do something like this:
The IF condition looks ok, you can modify the “&&” for “and”, but that is a question of style only.
If you are not certain about the record being retrieved from the database you can start a rails console and check the record, the command is:
rails c -s
This will start a rails console in sandbox mode (all your modifications will roll back after you quit the console).