no not dataset, connection is wrong. I tried to inbject in method but no luck. Jeremy, How can I inject connection (second_db in this example) using your way?
On Tuesday, December 25, 2018 at 10:31:42 PM UTC+3, genc wrote: > > Thanks Jeremy. > > But this time it doesn't see my dataset assignment. It used primary > connection in rails. I think I put these on wrong place: > > c = Sequel::Model(second_db) > c.set_dataset(source) > > Gencer. > > On Tuesday, December 25, 2018 at 9:32:23 PM UTC+3, Jeremy Evans wrote: >> >> On Tuesday, December 25, 2018 at 8:50:32 AM UTC-8, genc wrote: >>> >>> Hi Jeremy, >>> >>> I have models like this: >>> >>> >>> class Mailbox::Email < Mailbox::Model(:emails) >>> end >>> class Mailbox::Post < Mailbox::Model(:emails) >>> end >>> >>> >>> and of course a base class: >>> >>> module Mailbox >>> def self.Model(source) >>> c = Sequel::Model(second_db) >>> c.set_dataset(source) >>> end >>> >>> # defining admin? here not work as its inhertied from Model. >>> end >>> >> >> You want to use Class.new(Sequel::Model) to create the abstract base >> class, and def_Model to define the appropriate model method. Then you can >> use class_eval do define the methods shared by subclasses: >> >> module Mailbox >> Model = Class.new(Sequel::Model) >> Model.def_Model(self) >> Model.class_eval do >> def admin? >> is_admin || false >> end >> end >> end >> >> Thanks, >> Jeremy >> > -- 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 sequel-talk+unsubscr...@googlegroups.com. To post to this group, send email to sequel-talk@googlegroups.com. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.