Nope, it's not Rails magic.

Here's why I was having the same issues before:

If I manually require 'active_model' (in Rails or IRB or wherever) and
then load the plugin, I get the issue. (It wasn't the 5 terminal
windows!)

So, in IRB:

>> require 'sequel'
=> true
>> require 'active_model'
=> true
>> Sequel::Model.plugins
=> [Sequel::Model, Sequel::Model::Associations]
>> Sequel::Model.plugin :active_model
=> nil
>> Sequel::Model.plugins
=> [Sequel::Model, Sequel::Model::Associations, ActiveModel]

However, if I exclude loading ActiveModel and just let the plugin do
it:

>> require 'sequel'
=> true
>> Sequel::Model.plugins
=> [Sequel::Model, Sequel::Model::Associations]
>> Sequel::Model.plugin :active_model
=> nil
>> Sequel::Model.plugins
=> [Sequel::Model, Sequel::Model::Associations,
Sequel::Plugins::ActiveModel]

If you have some idea off the top of your head what is causing this,
that'd be great. In the meantime, I'll start looking through the code
and see if I can come up with a fix.

On Mar 23, 3:19 pm, cult hero <[email protected]> wrote:
> Man, I'm totally confused. I think all this "Rails Magic" is part of
> the problem. (Well, my lack of understanding of "Rails Magic" is the
> problem.)
>
> When I open up IRB (which is working, I think I just got my 5 terminal
> windows confused) and run "Sequel::Model.plugin :active_model" I get
> the following:
>
> >> Sequel::Model.plugins
>
> => [Sequel::Model, Sequel::Model::Associations,
> Sequel::Plugins::ActiveModel]
>
> And as I type this... I at least see part of the problem.
>
> When I do the same thing inside a rails console:
>
> >> Sequel::Model.plugins
>
> => [Sequel::Model, Sequel::Model::Associations, ActiveModel]
>
> So... there's the problem! It's some kind of namespace issue (yep,
> Rails Magic). I'm not sure how to get around it either.
>
> I get this after it's loaded from the initializer file I made above.
> Although moving it around to some other places yielded the same
> result.
>
> On Mar 23, 2:44 pm, Jeremy Evans <[email protected]> wrote:
>
>
>
> > On Mar 23, 11:01 am, cult hero <[email protected]> wrote:
>
> > > I don't know if it's bundler or some oddity that has to do with how
> > > Rails does things, but actually... it appears I was wrong. Running
> > > Sequel::Model.plugin :active_model doesn't appear to do anything
> > > inside Rails 3. In fact, unless I'm totally botching the way plugins
> > > work, it doesn't appear to work in Ramaze either or just running from
> > > IRB.
>
> > > None of the class or instance methods become available to my models or
> > > to Sequel::Model itself. Am I just missing something obvious or what?
>
> > > For what it's worth, Sequel::Model.plugin :active_model returns nil.
>
> > > (Incidentally, auto loading works fine, but the Rails console handles
> > > the loading when items are initially called which is different than
> > > what I've been used to.)
>
> > You need to be sure that Sequel::Model.plugin :active_model is called
> > before the model subclasses are loaded.  Sequel uses a copy on create
> > design philosophy for model classes, so once the subclass is created,
> > changes to the parent class are independent of changes to subclasses
> > created previously.
>
> > 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.

Reply via email to