Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

seems_rateable raises unknown method in Model #10

Open
rajatgarg79 opened this issue Jul 3, 2014 · 4 comments
Open

seems_rateable raises unknown method in Model #10

rajatgarg79 opened this issue Jul 3, 2014 · 4 comments

Comments

@rajatgarg79
Copy link

I have added gem to Gemfile and then installed it. All migrations have been run as well.

When I include seems_rateable in Product Model, it throws this error -
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in method_missing': undefined local variable or methodseems_rateable' for Product (call 'Product.connection' to establish a connection):Class (NameError)
from /var/www/marketplace/app/models/product.rb:23:in <class:Product>' from /var/www/marketplace/app/models/product.rb:1:in<top (required)>'

Any pointers on what I am missing?

I am using Rails 4.1.1

@petertoth
Copy link
Owner

Hello,
It looks like somehow gem's active record extension hasn't been extended into your ActiveRecord::Base yet. Does Product.ancestors include SeemsRateable::Models::ActiveRecordExtension::Rateable ?
I'll try to look deeper into the issue later.
Thanks for the feedback!

@rajatgarg79
Copy link
Author

It's not there. Here is a dump of Product.ancestors -

=> [Product(id: integer, name: string, description: text, available_on: datetime, deleted_at: datetime, slug: string, meta_description: text, meta_keywords: string, tax_category_id: integer, shipping_category_id: integer, created_at: datetime, updated_at: datetime, avg_rating: decimal, reviews_count: integer, asset_file_name: string, asset_content_type: string, asset_file_size: integer, asset_updated_at: datetime, category_id: integer, supplier_sku: string), Product::GeneratedAssociationMethods, Kaminari::ConfigurationMethods, Kaminari::ActiveRecordModelExtension, #Module:0x00000002ac4c00, ActiveRecord::Base, Paperclip::Schema, Paperclip::Validators::HelperMethods, Paperclip::Validators, Paperclip::Callbacks::Running, Paperclip::Callbacks, Paperclip::Glue, Kaminari::ActiveRecordExtension, CanCan::ModelAdditions, PaperTrail::Model, ActiveRecord::Store, ActiveRecord::Serialization, ActiveModel::Serializers::Xml, ActiveModel::Serializers::JSON, ActiveModel::Serialization, ActiveRecord::Reflection, ActiveRecord::Transactions, ActiveRecord::Aggregations, ActiveRecord::NestedAttributes, ActiveRecord::AutosaveAssociation, ActiveModel::SecurePassword, ActiveRecord::Associations, ActiveRecord::Timestamp, ActiveModel::Validations::Callbacks, ActiveRecord::Callbacks, ActiveRecord::AttributeMethods::Serialization, ActiveRecord::AttributeMethods::Dirty, ActiveModel::Dirty, ActiveRecord::AttributeMethods::TimeZoneConversion, ActiveRecord::AttributeMethods::PrimaryKey, ActiveRecord::AttributeMethods::Query, ActiveRecord::AttributeMethods::BeforeTypeCast, ActiveRecord::AttributeMethods::Write, ActiveRecord::AttributeMethods::Read, #Module:0x00000004607008, ActiveRecord::AttributeMethods, ActiveModel::AttributeMethods, ActiveRecord::Locking::Pessimistic, ActiveRecord::Locking::Optimistic, ActiveRecord::CounterCache, ActiveRecord::Validations, ActiveModel::Validations::HelperMethods, ActiveSupport::Callbacks, ActiveModel::Validations, ActiveRecord::Integration, ActiveModel::Conversion, ActiveRecord::AttributeAssignment, ActiveModel::ForbiddenAttributesProtection, ActiveRecord::Sanitization, ActiveRecord::Scoping::Named, ActiveRecord::Scoping::Default, ActiveRecord::Scoping, ActiveRecord::Inheritance, ActiveRecord::ModelSchema, ActiveRecord::ReadonlyAttributes, ActiveRecord::NoTouching, ActiveRecord::Persistence, ActiveRecord::Core, Object, HomeHelper, PP::ObjectMixin, ActiveSupport::Dependencies::Loadable, JSON::Ext::Generator::GeneratorMethods::Object, Kernel, BasicObject]

@rajatgarg79
Copy link
Author

Is there a chance that you will get to this sooner else, I will try finding something else. Please do let me know.

I appreciate all your work on this plugin

@petertoth
Copy link
Owner

I guess the problem is somewhere in the initialization order. I looks like

module SeemsRateable
  class Engine < ::Rails::Engine
    isolate_namespace SeemsRateable

    initializer :seems_rateable do
     ::ActiveSupport.on_load(:active_record) { extend SeemsRateable::Models::ActiveRecordExtension }

is executed after the loading of ActiveRecord. I'm still working on it so for the time being feel free to migrate to another solution.

I'll try to let you know If I make any progress.

Anyways, thanks for the feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants