tags_controller.rb 745 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. module Admin
  3. class TagsController < BaseController
  4. before_action :set_tag
  5. def show
  6. authorize @tag, :show?
  7. @time_period = (6.days.ago.to_date...Time.now.utc.to_date)
  8. end
  9. def update
  10. authorize @tag, :update?
  11. if @tag.update(tag_params.merge(reviewed_at: Time.now.utc))
  12. redirect_to admin_tag_path(@tag.id), notice: I18n.t('admin.tags.updated_msg')
  13. else
  14. @time_period = (6.days.ago.to_date...Time.now.utc.to_date)
  15. render :show
  16. end
  17. end
  18. private
  19. def set_tag
  20. @tag = Tag.find(params[:id])
  21. end
  22. def tag_params
  23. params.require(:tag).permit(:name, :display_name, :trendable, :usable, :listable)
  24. end
  25. end
  26. end