The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
918 B

  1. # frozen_string_literal: true
  2. module Admin
  3. class TagsController < BaseController
  4. before_action :set_tags, only: :index
  5. before_action :set_tag, except: :index
  6. before_action :set_filter_params
  7. def index
  8. authorize :tag, :index?
  9. end
  10. def hide
  11. authorize @tag, :hide?
  12. @tag.account_tag_stat.update!(hidden: true)
  13. redirect_to admin_tags_path(@filter_params)
  14. end
  15. def unhide
  16. authorize @tag, :unhide?
  17. @tag.account_tag_stat.update!(hidden: false)
  18. redirect_to admin_tags_path(@filter_params)
  19. end
  20. private
  21. def set_tags
  22. @tags = Tag.discoverable
  23. @tags.merge!(Tag.hidden) if filter_params[:hidden]
  24. end
  25. def set_tag
  26. @tag = Tag.find(params[:id])
  27. end
  28. def set_filter_params
  29. @filter_params = filter_params.to_hash.symbolize_keys
  30. end
  31. def filter_params
  32. params.permit(:hidden)
  33. end
  34. end
  35. end