aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_public_body_category_controller.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/admin_public_body_category_controller.rb b/app/controllers/admin_public_body_category_controller.rb
index 0fece725e..221d8e4ad 100644
--- a/app/controllers/admin_public_body_category_controller.rb
+++ b/app/controllers/admin_public_body_category_controller.rb
@@ -16,13 +16,22 @@ class AdminPublicBodyCategoryController < AdminController
end
def update
- I18n.with_locale(I18n.default_locale) do
- @category = PublicBodyCategory.find(params[:id])
+ @category = PublicBodyCategory.find(params[:id])
+ @tagged_public_bodies = PublicBody.find_by_tag(@category.category_tag)
+ heading_ids = []
+ I18n.with_locale(I18n.default_locale) do
if params[:public_body_category][:category_tag] && PublicBody.find_by_tag(@category.category_tag).count > 0 && @category.category_tag != params[:public_body_category][:category_tag]
flash[:notice] = 'There are authorities associated with this category, so the tag can\'t be renamed'
- elsif @category.update_attributes(params[:public_body_category])
- flash[:notice] = 'Category was successfully updated.'
+ else
+ if params[:headings]
+ heading_ids = params[:headings].values
+ end
+
+ if @category.update_attributes(params[:public_body_category])
+ @category.public_body_heading_ids = heading_ids
+ flash[:notice] = 'Category was successfully updated.'
+ end
end
render :action => 'edit'