I am not sure I know the best way to write this sql query in active record without totally writing it by hand. Essentially I want to write a combination of these two queries.

This query is essentially the join I am trying to re-create. I want to make sure any entries returned are only those with the images with a image\_path\_processing flag set to false.

```
@entries = ContestEntry.joins(:entry_images).where(contest_id: @contest.id, entry_images: {
        image_path_processing: false
        }).limit(10)

```

However the issue I am running into with the query I am writing is that I need to include params from a url and I am not sure that the above syntax is properly removing sql\_injection 

Here is what I am attempting to add the conditional join to.

```
@entries = ContestEntry.where("contest_id = ? and created_at > ?",
      params[:contest_id], Time.at(params[:after].to_i + 1))

```