Q:

Chained ruby on rails query to return those that are not nil

I am querying Active Record and want to chain two queries together.
My issue is that when I want to return those with an attribute that is not nil it doesn't return any records that I know exist:
user.change_requests.where("action_at = ?", req.action_at).where("cancelled_at != ?", nil)

This basically returns an empty array but I'm expecting an array of change_requests

A:

Max had the correct answer above in the comments. You can use the ActiveRecord where.not syntax when writing sql NOT.
From the ActiveRecord docs:

2.4 NOT Conditions
NOT SQL queries can be built by where.not:
Client.where.not(locked: true)
In other words, this query can be
  generated by calling where with no argument, then immediately chain
  with not passing where conditions. This will generate SQL like this:
SELECT * FROM clients WHERE (clients.locked != 1)

For your specific case, the code would look like:
user.change_requests.where(action_at: req.action_at).where.not(cancelled_at: nil)

