I am just starting out with Ruby. I am making a little app in Sinatra and I am using Datamapper with a sqlite3 db.
Below are the three models I have that I am creating.
class Team
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
property :created_at, DateTime
property :updated_at, DateTime
end
class Poll
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
property :created_at, DateTime
property :updated_at, DateTime
end
class Ranking
include DataMapper::Resource
property :year, Integer
property :week, Integer
property :ranking, Integer
property :votes, Integer
property :created_at, DateTime
property :updated_at, DateTime
belongs_to :team, :key => true
belongs_to :poll, :key => true
end
What I want to be able to do is query the Ranking model for a certain poll, week and year.
The returning result should be all the rankings for that poll with the associated team to each ranking number.
So get the ranking and corresponding team for each ranking for say 2011 - Week 1 or 2011 - Week 7, etc...
I have been trying all day to figure out how to get this to work and I am not getting anywhere, so that is why I am now posting here asking for help.