Skip to content

Commit

Permalink
Replaces class_eval logic from product_decorator.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
PSzyszkaSpark committed Dec 19, 2019
1 parent 98720b9 commit 41dbc94
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions app/models/spree/product_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ def self.prepended(base)
base.translates :name, :description, :meta_title, :meta_description, :meta_keywords, :slug, fallbacks_for_empty_translations: true
base.friendly_id :slug_candidates, use: [:history, :globalize]

base.translation_class.class_eval do |translation|
translation.acts_as_paranoid
translation.after_destroy :punch_slug
translation.default_scopes = []

def punch_slug
update(slug: "#{Time.now.to_i}_#{slug}")
end
end
base.translation_class.acts_as_paranoid
base.translation_class.after_destroy :punch_slug
base.translation_class.default_scopes = []
base.translation_class.define_method(:punch_slug) { update(slug: "#{Time.now.to_i}_#{slug}") }

def base.like_any(fields, values)
translations = Spree::Product::Translation.arel_table
Expand Down

0 comments on commit 41dbc94

Please sign in to comment.