Class: SportDb::Model::Team
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SportDb::Model::Team
- Defined in:
- lib/sportdb/models/models/team.rb,
lib/sportdb/models/models/forward.rb
Instance Method Summary collapse
-
#matches ⇒ Object
fix!!! - how to do it with has_many macro? use finder_sql? finder_sql is depreciated in Rails 4!!! use -> { where() } etc.
- #past_matches ⇒ Object
- #upcoming_matches ⇒ Object
Instance Method Details
#matches ⇒ Object
fix!!! - how to do it with has_many macro? use finder_sql?
finder_sql is depreciated in Rails 4!!!
use -> { where() } etc. -- try it if it works
keep as is! best solution ??
a discussion here -> https://github.com/rails/rails/issues/9726
a discussion here (not really helpful) -> http://stackoverflow.com/questions/2125440/activerecord-has-many-where-two-columns-in-table-a-are-primary-keys-in-table-b
35 36 37 |
# File 'lib/sportdb/models/models/team.rb', line 35 def matches Match.where( 'team1_id = ? or team2_id = ?', id, id ).order( 'date' ) end |
#past_matches ⇒ Object
43 44 45 |
# File 'lib/sportdb/models/models/team.rb', line 43 def past_matches Match.where( 'team1_id = ? or team2_id = ?', id, id ).where( 'date < ?', Date.today ).order( 'date desc' ) end |
#upcoming_matches ⇒ Object
39 40 41 |
# File 'lib/sportdb/models/models/team.rb', line 39 def upcoming_matches Match.where( 'team1_id = ? or team2_id = ?', id, id ).where( 'date > ?', Date.today ).order( 'date' ) end |