Forum: Ruby on Rails complicated search/model question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hugh Kelsey (Guest)
on 2006-02-08 00:53
(Received via mailing list)
Hi,

I have the models and db below and am putting together a scheduling
application.
With what is laid out below (or any suggested changes) how would I find
a
contractor for a job based on the contractor being available on a
specific
weekday, at a specific time and not currently booked in to a job during
the
same time?

I?m new to Ruby and Rails and making pretty good progress but I must
admit I
have no idea were to start on this.

Thanks in advance for any help,

Hugh

contractor.rb
has_many :jobs
has_many :availabilities

job.rb
belongs_to :contractor

availability.rb
belongs_to :contactor


create_table "availabilities", :force => true do |t|
    t.column "contractor_id", :integer
    t.column "day", :integer # 0-6 to match  ruby wday
    t.column "available_from", :datetime # could be just a time field
but rails
doesn't seam to play nice with time objects
    t.column "available_to", :datetime # could be just a time field but
rails
doesn't seam to play nice with time objects
    t.column "start_date", :date # used if a contractor available only
between
certain dates
    t.column "end_date", :date # used if a contractor available only
between
certain dates
    t.column "comments", :string
    t.column "created_at", :datetime
    t.column "update_at", :datetime
  end

  create_table "jobs", :force => true do |t|
    t.column "created_at", :datetime
    t.column "updated_at", :datetime
    t.column "contractor_id", :integer
    t.column "date_time", :datetime
    t.column "duration", :float
    t.column "booking_id", :integer
    t.column "confirmed", :datetime
    t.column "cancelled", :datetime
  end

  create_table "contractors", :force => true do |t|
    t.column "created_at", :datetime
    t.column "updated_at", :datetime
    t.column "first_name", :string
    # plus a bunch more
  end

end

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
This topic is locked and can not be replied to.