SQL OR in RoR

I am new to RoR and I am trying to convert one of my old PHP
applications into RoR.

However, I am not having any luck finding out how to do an OR statement
in RoR. My old statement in PHP is as follows...

SELECT * FROM games WHERE home_team = {param} or away_team = {param}
ORDER BY game_date ASC

I can do the OR in the model but I can't find a way to pass the param
through.

I can pass the param in the controller but I can't find an OR statement
that will work.

I have also tried putting multiple statements together in the controller
but then I can't order them the way I want...

@home = Game.sorted.where(:home_team => params[:id])
@visitor = Game.sorted.where(:away_team => params[:id])
@games = @home + @visitors
#@games is what I refer to in the games.html.erb page but it sorts the
home games and then the visitor games so they aren't in order.

There has to be a way to do this. What am I missing?

Thanks
Mike

@games = Game.sorted.where(“home_team = :id OR away_team = :id”, id: params[:id])

``

That should do the trick for you. You can have a string inside of your where statement that equates to SQL. You can then have named parameters that are used throughout the query as I have done above. In this case you are using the same variable for both but you could include more values in the hash at the end to be used in your query.

Thanks Eric.

That did the trick.