<commit_before>module Controller
  module ActsAsPublishedConcern
    extend ActiveSupport::Concern

    def toggle_published
      @resource = load_resource
      @resource.toggle_published!
      action_taken = @resource.published? ? 'published' : 'unpublished'
      resource_label = @resource.try_all(*Itsf::Backend::Configuration.resource_title_methods)
      redirect_to :back, notice: I18n.t("acts_as_published.notices.#{action_taken}", name: resource_label)
    end
  end
end
<commit_msg>Use redirect_back for rails > 5.<commit_after>module Controller
  module ActsAsPublishedConcern
    extend ActiveSupport::Concern

    def toggle_published
      @resource = load_resource
      @resource.toggle_published!

      action_taken = @resource.published? ? 'published' : 'unpublished'
      resource_label = @resource.try_all(*Itsf::Backend::Configuration.resource_title_methods)
      if Rails.version < '5.0.0'
        redirect_to :back, notice: I18n.t("acts_as_published.notices.#{action_taken}", name: resource_label)
      else
        flash[:notice] = I18n.t("acts_as_published.notices.#{action_taken}", name: resource_label)
        redirect_back(fallback_location: main_app.root_path)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09787928221859707, 'fraction_numerical': 0.008156606851549755, 'mean_word_length': 4.243589743589744, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1217873', 'n_tokens_mistral': 384, 'n_tokens_neox': 364, 'n_words': 67}