app/controllers/spree/admin/taxons_controller.rb in spree_backend-4.2.7 vs app/controllers/spree/admin/taxons_controller.rb in spree_backend-4.3.0.rc1
- old
+ new
@@ -49,11 +49,11 @@
# rename child taxons
rename_child_taxons if @update_children
respond_with(@taxon) do |format|
- format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
+ format.html { redirect_to spree.edit_admin_taxonomy_url(@taxonomy) }
format.json { render json: @taxon.to_json }
end
else
respond_with(@taxon) do |format|
format.html { render :edit }
@@ -63,11 +63,11 @@
end
def remove_icon
if @taxon.icon.destroy
flash[:success] = Spree.t('notice_messages.icon_removed')
- redirect_to edit_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.id)
+ redirect_to spree.edit_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.id)
else
flash[:error] = Spree.t('errors.messages.cannot_remove_icon')
render :edit
end
end
@@ -88,23 +88,23 @@
@taxon = @taxonomy.taxons.find(params[:id])
end
def load_taxonomy
@taxonomy = if defined?(SpreeGlobalize)
- Taxonomy.includes(:translations, taxons: [:translations]).find(params[:taxonomy_id])
+ scope.includes(:translations, taxons: [:translations]).find(params[:taxonomy_id])
else
- Taxonomy.find(params[:taxonomy_id])
+ scope.find(params[:taxonomy_id])
end
end
def set_position
new_position = params[:taxon][:position]
@taxon.child_index = new_position.to_i if new_position
end
def set_parent(parent_id)
- @taxon.parent = Taxon.find(parent_id.to_i) if parent_id
+ @taxon.parent = current_store.taxons.find(parent_id.to_i) if parent_id
end
def set_permalink_params
if params.key? 'permalink_part'
params[:taxon][:permalink] = @parent_permalink + params[:permalink_part]
@@ -124,9 +124,13 @@
def reload_taxon_and_set_permalink(taxon)
taxon.reload
taxon.set_permalink
taxon.save!
+ end
+
+ def scope
+ current_store.taxonomies
end
end
end
end