spree-contrib/spree_i18n

`method_missing': undefined method `whitelisted_ransackable_associations'

picazoH opened this issue · 10 comments

I have a problem executing rake assets:precompile, is like there's an include missing

I'm with a 2-4-stable, spree & spree i18_n

/home/hector/.rvm/gems/ruby-2.2.2/gems/activerecord-4.1.11/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `whitelisted_ransackable_associations' for #<Class:0x00000007380b38> (NoMethodError)
    from /home/hector/.rvm/gems/ruby-2.2.2/bundler/gems/spree_i18n-e911bd11b4df/app/models/spree_i18n/translatable.rb:7:in `block in <module:Translatable>'
    from /home/hector/.rvm/gems/ruby-2.2.2/gems/activesupport-4.1.11/lib/active_support/concern.rb:120:in `class_eval'
    from /home/hector/.rvm/gems/ruby-2.2.2/gems/activesupport-4.1.11/lib/active_support/concern.rb:120:in `append_features'

is your spree up to date?
that method is a very recent addition

Yes is up to date, latest 2-4-stable branch, I think there is a problem with the translatable.rb that can not find the Concern RansackableAttributes

I solved with an include, but I'm sure there is a better way.

module SpreeI18n
  module Translatable
    extend ActiveSupport::Concern
    #include Spree::RansackableAttributes

    included do |klass|
      accepts_nested_attributes_for :translations
      klass.whitelisted_ransackable_associations |= ['translations']
    end
  end
end

I have the same issue:
spree (3.1.0.beta 2c8efc2), spree_globalize (3.1.0.beta f119998), spree_i18n (3.1.0.beta 3204a24)

running : rails g spree:globalize:install

/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/dynamic_matchers.rb:26:in method_missing': undefined methodwhitelisted_ransackable_associations' for #Class:0x007f2db06437e8 (NoMethodError)

i just added spree_i18n to a spree 2.4.4, got this error and solved with bundle update spree (now 2.4.10)

Hi @alepore, working now wit a clean 2-4-stable, thank you

remote: https://github.com/spree/spree.git
revision: ef635b9427a3e1f458091cd81cea4c2ae11cf335
branch: 2-4-stable

remote: https://github.com/spree/spree_i18n.git
revision: cd9201e66e140a9376a2f73fa1cd00ad57c67f7c
branch: 2-4-stable

I am having this issue on a pristine installation. My Gemfile:

gem 'spree', '3.0.1'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: '3-0-stable'

Use the latest spree version @donatoaz it's not introduced until then. Same for people on older branches make sure both spree_i18n and spree are completely up to date.

I updated dependency to the latest spree version to help this

I'm in the process of upgrading from 2.3 to 2.4, and I got this error while trying to run rake db:migrate to install run the new migrations after installing them. Using these gems (among others):

gem 'rails', '~> 4.1.8'
gem 'spree', github: 'spree/spree', branch: '2-4-stable'
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => '2-4-stable'
gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', :branch => '2-4-stable'
gem 'spree_i18n', github: 'spree/spree_i18n', branch: '2-4-stable'
gem 'spree_bootstrap_frontend', github: '200Creative/spree_bootstrap_frontend', branch: '2-4-stable'

gem 'spree_static_content', github: 'spree/spree_static_content', branch: '2-4-stable'
gem 'spree_multilingual_static_content', :github => "endenis/spree-multilingual-static-content"

gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: '2-4-stable'

# For paypal express
gem 'spree_paypal_express', :github => "radar/better_spree_paypal_express", :branch => "2-4-stable"

another tip: make sure your translated custom models inherits from Spree::Base and not ActiveRecord::Base