Okay, this doesn't make any sense.  This should work:

def self.start(teamone, teamtwo)

  week_start_date 
=Time.now.beginning_of_week.to_date.strftime('%Y-%m-%d')
  week_end_date = Time.now.end_of_week.to_date.strftime('%Y-%m-%d')
  compiled_on = week_start_date..week_end_date
  Team.find( teamone, teamtwo,
    :select => "teams.name, tsrs_ratings.tsrs, rushing_offenses.ydspg",
    :joins => [ :tsrs_ratings, :rushing_offenses ],
    :conditions => { :tsrs_ratings => {:compiled_on  => compiled_on},
      :rushing_offenses => {:compiled_on => compiled_on} },
    :order => "teams.id" )

end

SQL returns (from development.log):

SELECT teams.name, tsrs_ratings.tsrs, rushing_offenses.ydspg
FROM `teams`
INNER JOIN `tsrs_ratings` ON tsrs_ratings.team_id = teams.id
INNER JOIN `rushing_offenses` ON rushing_offenses.team_id = teams.id
WHERE (`teams`.`id` IN (10,12) AND (`tsrs_ratings`.`compiled_on` BETWEEN 
'2009-07-20' AND '2009-07-26' AND `rushing_offenses`.`compiled_on` 
BETWEEN '2009-07-20' AND '2009-07-26')) ORDER BY teams.id

If I take the same sql statement returned from the development log and 
place into mysql directly I get:

name  tsrs  ydspg
Florida 112.005 231.14
TCU 99.0148 220.23

Yet if I try to reference it in rails:

test = Virtual.start(10,12)

test[0]
=> #<Team name: "Florida">

test[0].tsrs_ratings
=> []

test[0].tsrs_ratings[0]
=> nil

What gives??


-- 
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to