We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scenario:
Use enumerated_attribute on some models, then try to use sunspot gem.
When you declare a model to be searchable using sunspot, then attempt to do rake sunspot:solr:reindex to build your index, you get:
rake sunspot:solr:reindex
rake aborted! method_missing_without_enumerated_attribute already exists. Circular references not permitted. /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/meta_programming-0.2.2/lib/meta_programming/object.rb:43:in `block in safe_alias_method_chain' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/meta_programming-0.2.2/lib/meta_programming/object.rb:39:in `class_eval' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/meta_programming-0.2.2/lib/meta_programming/object.rb:39:in `safe_alias_method_chain' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/meta_programming-0.2.2/lib/meta_programming/object.rb:66:in `define_chained_method' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/bundler/gems/enumerated_attribute-84221b872f7f/lib/enumerated_attribute/integrations/active_record.rb:107:in `singletonclass' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/bundler/gems/enumerated_attribute-84221b872f7f/lib/enumerated_attribute/integrations/active_record.rb:94:in `block in define_enumerated_attribute_new_method' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/bundler/gems/enumerated_attribute-84221b872f7f/lib/enumerated_attribute/integrations/active_record.rb:93:in `class_eval' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/bundler/gems/enumerated_attribute-84221b872f7f/lib/enumerated_attribute/integrations/active_record.rb:93:in `define_enumerated_attribute_new_method' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/bundler/gems/enumerated_attribute-84221b872f7f/lib/enumerated_attribute/attribute.rb:45:in `create_enumerated_attribute' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/bundler/gems/enumerated_attribute-84221b872f7f/lib/enumerated_attribute.rb:13:in `enumerated_attribute' /Users/aisrael/workspaces/rails/likejobs/web/app/models/user.rb:22:in `<class:User>' /Users/aisrael/workspaces/rails/likejobs/web/app/models/user.rb:1:in `<top (required)>' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/sunspot_rails-1.3.3/lib/sunspot/rails/tasks.rb:34:in `block (3 levels) in <top (required)>' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/sunspot_rails-1.3.3/lib/sunspot/rails/tasks.rb:34:in `each' /Users/aisrael/.rvm/gems/ruby-1.9.3-p327/gems/sunspot_rails-1.3.3/lib/sunspot/rails/tasks.rb:34:in `block (2 levels) in <top (required)>' Tasks: TOP => sunspot:solr:reindex => sunspot:reindex (See full trace by running task with --trace)
This happens even if the searchable model itself doesn't declare any enumerated_attributes.
The text was updated successfully, but these errors were encountered:
I just discovered that you don't even need sunspot gem. If you have
class User < ActiveRecord::Base enum_attr :test, %w(a b c)
Then it's enough to go
$ rails console > class User > enum_attr :foo, %w(d e f)
And you'll get the same error. From what I can tell, in enumerated_attribute/integrations/active_record.rb the following guard:
enumerated_attribute/integrations/active_record.rb
unless private_method_defined?(:method_missing_without_enumerated_attribute)
is failing.
Sorry, something went wrong.
Found it. The check in meta_programming/lib/meta_programming/object.rb:42 checks for both public and private methods:
meta_programming/lib/meta_programming/object.rb:42
if (method_defined?(method_name_with_ext) || private_method_defined?(method_name_with_ext)) raise(MetaProgramming::AliasMethodChainError, "#{method_name_without_ext} already exists. Circular references not permitted.")
Whereas the guard in enumerated_attribute/integrations/active_record.rb:106 only checks for private methods. It should be changed to:
enumerated_attribute/integrations/active_record.rb:106
unless method_defined?(:method_missing_without_enumerated_attribute) || private_method_defined?(:method_missing_without_enumerated_attribute)
Forking, patching, submitting a pull request.
fixes jeffp#60 check if method exists, private & public
c6aab3e
No branches or pull requests
Scenario:
Use enumerated_attribute on some models, then try to use sunspot gem.
When you declare a model to be searchable using sunspot, then attempt to do
rake sunspot:solr:reindex
to build your index, you get:This happens even if the searchable model itself doesn't declare any enumerated_attributes.
The text was updated successfully, but these errors were encountered: