Robert, object_id is a Ruby method that returns the actual id of the object.
2.0.0p247 :001 > nil.object_id => 8 2.0.0p247 :002 > Integer.object_id => 70357008963380 2.0.0p247 :003 > Object.object_id => 70357008981160 2.0.0p247 :004 > It's a special method and you were trying to override it. I think it's just a case of a bad choice of a column name. Luke On Sat, Oct 19, 2013 at 6:42 AM, Robert Payne <[email protected]> wrote: > Little further investigate maybe it's because of the suffix "id" it > appears? If I change to just "object_i" it works fine.. > > On Saturday, October 19, 2013 11:39:27 PM UTC+13, Robert Payne wrote: >> >> So I'm having this extremely weird issue with an integer column not being >> available via instance method in a before/after save hook. See below test >> code: >> >> require 'sequel' >> >> DB = Sequel.sqlite(':memory:') >> >> DB.create_table(:**notifications_jobs) do >> primary_key :id >> String :object_kind, size: 60, null: false >> Integer :object_id, null: false >> end >> >> class NotificationJob < Sequel::Model(:notifications_**jobs) >> >> protected >> >> def before_save >> puts "#{self.object_kind}, #{self[:object_kind]}" >> puts "#{self.object_id}, #{self[:object_id]}" >> end >> >> end >> >> NotificationJob.create(object_**kind: 'hello', object_id: 5) >> >> If you run this small example object_kind is available via the instance >> method but the integer returns what I'm assuming is the maximum integer >> value in Ruby likely due to it being undefined? >> >> Is this intended functionality / should I be doing this differently? >> >> Cheers, >> Robert >> > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sequel-talk. > For more options, visit https://groups.google.com/groups/opt_out. > -- Luke Ehresman [email protected] Tebros Systems - http://tebros.com -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/groups/opt_out.
