Skip to content

Commit

Permalink
Override Admin::ResourceController#parent method
Browse files Browse the repository at this point in the history
This is not very nice but it's needed to avoid the use of `find_by_slug`, which
doesn't work with Globalize 5.1 because it removes the slug column.

This is only needed on Solidus versions from 2.0 to 2.2 because it's already
fixed in 2.3.
  • Loading branch information
alepore committed Aug 24, 2017
1 parent 7c631a2 commit d39c3d1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/controllers/spree/admin/resource_controller_decorator.rb
@@ -0,0 +1,13 @@
module SolidusGlobalize::ResourceControllerDecorator
def parent
if parent_data.present?
@parent ||= parent_data[:model_class].find_by(parent_data[:find_by] => params["#{model_name}_id"])
instance_variable_set("@#{model_name}", @parent)
end
end
end

if SolidusSupport.solidus_gem_version >= Gem::Version.new("2.0") &&
SolidusSupport.solidus_gem_version < Gem::Version.new("2.3")
Spree::Admin::ResourceController.prepend(SolidusGlobalize::ResourceControllerDecorator)
end

0 comments on commit d39c3d1

Please sign in to comment.