On Tuesday, October 9, 2012 11:07:24 PM UTC+2, JoeLoui wrote: > > Hi, I stuck trying to find how to solve this: I have a 2 models (Bar1, > Bar2) which shares similar behaviour but different tables and because > of that exists a Foo class which is a Sequel model (it's a Sequel > model because I don't want to repeat validations and callbacks) from > where Bar1 and Bar2 inheritates some behaviour. > > I'm using set_dataset to tell Sequel what table to use for Bar1 and > Bar2, but how can I tell to Sequel that Foo doesn't have a table? > > In the IRC channel Jeremy gave me a hint, he told me I can use an > anonymous class like this: > > Foo = Class.new(Sequel::Model) > > I try to use this in my code like this: > > Foo = Class.new(Sequel::Model) > class Foo > ... > end > > But I get this error: No dataset associated with Foo > > Then I tried the following > > Foo = Class.new(Sequel::Model) do > ... > end > > And this time I get this: No dataset associated with #<Class: > 0x00000002d54830> > > So I don't know how to work this out... Any hints? >
If you get an error, always provide the full backtrace and full code, and if it is an SQL error, an SQL log, otherwise it's hard to determine where the actual problem is. My guess is the problem is in some code that you did not post here. Most likely you are doing something with Foo that requires a dataset, and you haven't given it one. You shouldn't be doing anything that requires a dataset if you are trying to use it as an abstract base class. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/LOqux37IGHgJ. 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.
