OK, I'm getting confused with the foo, bar, baz thing. I'm trying to do
something very similar (in fact I was going to ask before I saw this
thread). I have a library app. with books and locations. Each book can have
many locations and each location can have many books. What I'm trying to add
is a "total" and a "checked_out" value for each book at each location. Based
on the above, what I have for my tables are (from my migration):
create_table(:books) do
primary_key :id
String :title
end
create_table(:locations) do
primary_key :id
String :location
end
create_table(:books_locations) do
primary_key :id
foreign_key :location_id, :locations
foreign_key :book_id, :books
Integer :total
Integer :checked_out
end
and my models:
class Book < Sequel::Model
many_to_many :locations
end
class Location < Sequel::Model
many_to_many :books
end
class BookLocations < Sequel::Model(:books_locatons)
many_to_one :books
many_to_one :locations
end
The BookLocations is what I gather from Jeremy's post that I need (should
those lines be "many_to_many" though?
Now though, I'm not sure what I need to add to the Book model to let me add
count and checked_out values (and change them) for a given destination.
Thoughts?
Scott
On Sat, Jul 11, 2009 at 1:58 PM, Clive Crous <[email protected]> wrote:
>
> 2009/7/11 Jeremy Evans <[email protected]>:
> > I was thinking *args. If we are going to add additional flexibility
> > in this area, there's no reason to restrict it to a single hash.
>
> I thought so too, however I thought best to make sure. One never knows
> what's possibly planned "down the line" in a project you're not
> directly involved in ;)
>
> Thanks,
> Clive
>
> >
>
--
Scott
http://steamcode.blogspot.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---