<commit_before>class CategoriesController < ApplicationController
  before_action :authenticate_user!
  before_action :find_destination, only: %i[index new create]
  before_action :current_category, only: %i[show edit update destroy]

  def index
    @categories = current_user.try(:categories)
  end

  def new
    @category = @destination.categories.build
  end

  def create
    @category = Category.new(category_params)
    @category.destination_ids = params[:destination_id]
    if @category.save
      redirect_to @category
    else
      render :new
    end<commit_msg>added json endpoint to categories controller#index<commit_after>class CategoriesController < ApplicationController
  before_action :authenticate_user!
  before_action :find_destination, only: %i[index new create]
  before_action :current_category, only: %i[show edit update destroy]

  def index
    @categories = current_user.try(:categories)
    respond_to do |f|
      f.html { render :index }
      f.json { render json: @categories }
    end
  end

  def new
    @category = @destination.categories.build
  end

  def create
    @category = Category.new(category_params)
    @category.destination_ids = params[:destination_id]
    if @category.save
      redirect_to @category
    else
      render :new
    end
{'fraction_non_alphanumeric': 0.07739938080495357, 'fraction_numerical': 0.0, 'mean_word_length': 3.879245283018868, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3419611', 'n_tokens_mistral': 370, 'n_tokens_neox': 361, 'n_words': 99}