On Tuesday, February 18, 2014 5:25:14 PM UTC-8, [email protected] wrote:
>
> I fixed an issue but the contributing
> guidelines<https://github.com/jeremyevans/sequel/blob/master/CONTRIBUTING>
> and
> was about to issue a pull request but the scared me off - I'm posting here
> first to validate that this is pull-request worthy.
>
> The problem:
>
> Gemfile:
>
>> rails 4.0.2
>> sequel
>> sequel-rails
>> devise
>> sequel-devise
>
>
> User class:
>
>> class OrganizationUser < Sequel::Model
>> plugin :devise
>> devise :database_authenticatable
>> end
>
>
> works fine but if i add *:confirmable* to the devise plugin list so line
> #3 changes to:
>
>> devise :database_authenticatable, :confirmable
>
>
> an exception is thrown:
>
>> wrong number of arguments (2 for 0..1)
>
>
> I tracked this down to the fact that devise passes not one but two
> arguments to the *before* and *after* hooks (in addition to the method
> tag there's also a hash containing a key *:if *and value of another
> method to call) (see
> https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb#L36
> )
>
> feel free to take a quick look at my commit:
> https://github.com/hackerhasid/sequel/commit/ffc5ca8da5c43de6504c7295ecbd17d33c8f025b-
> i really didn't do any more than the minimum to get this use case working
>
Thanks for reading the contribution guidelines and asking here first.
This is not something I want to add to Sequel. The hook_class_methods
plugin is only for backwards compatibility with Sequel 2, it's not designed
to provide an ActiveRecord-compatible API (and I do not want that to become
a goal). If you can't get devise to change their code, I'd recommend
adding a separate plugin that offers a compatible API:
module ARHook
def self.apply(model)
model.plugin :hook_class_methods
end
module ClassMethods
Model::HOOKS.each{|h| class_eval("def #{h}(method = nil, opts=OPTS,
&block); super(method, &block) if !opts[:if] || send(opts[:if]) end",
__FILE__, __LINE__)}
end
end
Note that it is constructions like this (:if option as opposed to normal
ruby if expression) which show why hooks as instance methods are a better
approach.
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 [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.