Skip to content

Commit a1c3530

Browse files
committed
Extract the loading of the taxon in a method to allow an easier overriding
Update CHANGELOG
1 parent 89f7dae commit a1c3530

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- The promotions "Advertise" checkbox and the "URL Path" promotion activation method have been removed from the admin UI because the features are not implemented in solidus_frontend [#2737](https://github.com/solidusio/solidus/pull/2737) ([benjaminwil](https://github.com/benjaminwil)
66

7+
### Frontend
8+
9+
- The `TaxonsController#show` action loads now the `@taxon` in a `before_action` callback. This means that if you overrode the `show` method you may be loading the `@taxon` variable twice. You can now change the behaviour of how the `@taxon` is loaded overriding the `load_taxon` method instead. [#2782](https://github.com/solidusio/solidus/pull/2782) ([coorasse](https://github.com/coorasse))
10+
711
## Solidus 2.6.0 (2018-05-16)
812

913
### Major changes

frontend/app/controllers/spree/taxons_controller.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ module Spree
44
class TaxonsController < Spree::StoreController
55
helper 'spree/products', 'spree/taxon_filters'
66

7+
before_action :load_taxon, only: [:show]
8+
79
respond_to :html
810

911
def show
10-
@taxon = Spree::Taxon.find_by!(permalink: params[:id])
11-
return unless @taxon
12-
1312
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true))
1413
@products = @searcher.retrieve_products
1514
@taxonomies = Spree::Taxonomy.includes(root: :children)
1615
end
1716

1817
private
1918

19+
def load_taxon
20+
@taxon = Spree::Taxon.find_by!(permalink: params[:id])
21+
end
22+
2023
def accurate_title
2124
if @taxon
2225
@taxon.seo_title

0 commit comments

Comments
 (0)