I'm building a Sinatra application using three database tables: user
, post
, and like
.
I'd want to run a query that will find an entry in the like
table like so:
FIND in like WHERE user_id == params[:user_id] AND post_id == params[:post_id]
(for one condition, I'll be using: Like.find_by_user_id(params[:user_id])
)
My Question
How to run a find query with multiple conditions using the ActiveRecord
Gem?
Use
where
:or
Is important to keep in mind that the paremeters of the where need to be converted to the expected type for example
params[:post_id].to_i