Suppose I have a one to many relation like so...

class Bar < Sequel::Model
  one_to_many :foos
end


class Foo < Sequel::Model
  many_to_one :bar
end


...and I'd like to get a "previous foo" method that can be called on an 
instance. I can do it like this:

# inside class Foo
def previous_foo
  this = self
  bar.foos.order(:created_at).first{created_at < this.created_at}
end


This all works fine fine, but setting `this = self` to distinguish the 
instance value from the database column feels a little odd. Is there a 
better recommended way to do this in Sequel?

Thanks!
Andrew

-- 
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/d/optout.

Reply via email to