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

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/891f7231a3e359c42e677c552bec0971%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to