On Sep 11, 5:52 am, "[email protected]" <[email protected]> wrote: > I have a simple model setup: > > class Badge < Sequel::Model > many_to_many :players > end > > class Player < Sequel::Model > many_to_many :badges > end > > The "map" table is "badges_players", and there's no model but the > schema is basically: > > create_table(:badges_players) do > foreign_key :badge_id, :badges > foreign_key :player_id, :players > Time :created_at, :null => false > end > > I can't figure out how to get Sequel to set the "created_at" column > when doing: > > @player.add_badge(badge)
The easiest way is to add a database default value for the column. > I tried creating a model for the "badges_players" table, but > associations doesn't seem to ever use the model no matter what I do. > This seems like something that shouldn't be as complicated as I think > I'm making it. Anyone have any advice? If you don't want to add a database default, you can override _add_badge and do the insertion into the badges_players table yourself, including a value for the created_at column. But the database default is the easier and recommended approach. Jeremy -- 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.
