Skip to content

Conversation

@rabbitbike
Copy link

@rabbitbike rabbitbike commented Sep 28, 2023

I had an issue when running bundle exec rake solidus_avatax_certified:load_seeds as described in step 3 of the Installation steps in the readme.

I got the following error.

/[...]/gems/ruby-3.2.2/gems/activerecord-7.0.7.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `find_by_name' for Spree::Zone:Class (NoMethodError)

The reason is that the dynamic finder find_by_name cannot be used when that field is overridden for translation with globalize gem. I have access to globalize via solidus_globalize.

The name field of Spree::Zone is overridden in app/overrides in my project as below.

module Zone
  def self.prepended(base)
	base.translates :name, fallbacks_for_empty_translations: true
	base.include SolidusGlobalize::Translatable
 	[…]
   end
  ::Spree::Zone.prepend self
end

I guess there are those who would want to make Zone and Country models translatable with solidus_globalize / globalize.

If there is no particular reason for using the dynamic finder for these 2 models, I would like to suggest using the more conventional find_by(name: <value>).

Thank you for your consideration.

@rabbitbike rabbitbike changed the title Fix seeder error when used with solidus_globalize Fix seeder error when overriding Spree::Zone name field with globalize Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant