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