The plugin solution is perfect. Thanks for the quick reply! On Apr 18, 11:34 am, Jeremy Evans <[email protected]> wrote: > On Wednesday, April 18, 2012 7:57:12 AM UTC-7, mikeymo wrote: > > > I'm loving Sequel..thanks Jeremy. Quick question: I'm talking to a > > legacy SQL Server database that has a TIMESTAMP column which gets > > updated automatically by SQL Server on every update. I'm using JRuby > > with the jdbc adapter and when I try to update the Model, I'm getting: > > > "Cannot update a timestamp column" > > > Is there a way to specify (on a per Model basis) colum(s) to ignore > > when doing inserts/updates? Thanks again! > > I'd just remove the column in a before hook: > > def before_save > values.delete(:column_name) > super > end > > Since you have the database modifying column values during an update, > you'll want to refresh after updating: > > def after_update > super > refresh > end > > It would be fairly easy to package this as a plugin so that you could just > do: > > plugin :ignore_columns, [:column1, :column2] > > in your model class, and it would automatically set up the before_save and > after_update hooks. > > 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.
