Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Task.find(:all,
- :select => "distinct tasks.*",
- :joins => "inner join users on tasks.user_id = users.id inner join time_entries on time_entries.task_id = tasks.id",
- :conditions => ["users.id = ? and time_entries.task_date >= ? and time_entries.task_date <= ?",
- @user.id,
- '2007-06-18',
- '2007-06-24']).map{|t| t.project.name}
- ## could that be rewritten like so?
- class User
- has_many :time_entries, :through => :tasks
- end
- @user.time_entries.find_all_by_task_date(Date(2007,6,18)..Date(2007,6,24)).map{|t| t.project.name }
Add Comment
Please, Sign In to add comment