Skip to content

Commit

Permalink
Improving taxon edit
Browse files Browse the repository at this point in the history
If there was any error when trying to edit a taxon, it
was not showing any error and just redirecting to taxons index,
this change renders edit form showing errors correctly instead
of just redirect without any flash message.
  • Loading branch information
softr8 committed Apr 2, 2020
1 parent 68cad80 commit acdadf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion backend/app/controllers/spree/admin/taxons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def update
end

respond_with(@taxon) do |format|
format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
format.html do
if @taxon.valid?
redirect_to edit_admin_taxonomy_url(@taxonomy)
else
render :edit
end
end
end
end

Expand Down
3 changes: 1 addition & 2 deletions core/app/models/spree/taxon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class Taxon < Spree::Base
has_many :promotion_rule_taxons
has_many :promotion_rules, through: :promotion_rule_taxons

before_create :set_permalink
before_update :set_permalink
before_validation :set_permalink
after_update :update_child_permalinks, if: :saved_change_to_permalink?

validates :name, presence: true
Expand Down

0 comments on commit acdadf8

Please sign in to comment.