Sha256: bb70f6275e658d27725b78aa3a755e6f15fdb2efc59fd651241f69c0c7ba68f3
Contents?: true
Size: 1.82 KB
Versions: 5
Compression:
Stored size: 1.82 KB
Contents
require_dependency 'censor_bear/application_controller' module CensorBear class StopWordsController < ApplicationController before_action :set_stop_word, only: [:show, :edit, :update, :destroy] def index load_stop_words end def show; end def new @stop_word = StopWord.new end def edit; end def create @stop_word = StopWord.new(stop_word_params) @stop_word.user = current_user if @stop_word.save redirect_to @stop_word, notice: 'Stop word was successfully created.' else render :new end end def update if @stop_word.update(stop_word_params) redirect_to @stop_word, notice: 'Stop word was successfully updated.' else render :edit end end def destroy @stop_word.destroy respond_to do |format| format.turbo_stream format.html { redirect_to stop_words_url, notice: 'Stop word was successfully destroyed.' } end end def load_stop_words builder ||= stop_word_scope builder = builder.where('key ilike ?', "%#{params[:q]}%") if params[:q].present? case params[:filter] when 'size_one' builder = builder.where('length(key) = 1') when 'size_two' builder = builder.where('length(key) = 2') when 'size_three' builder = builder.where('length(key) = 3') end builder = builder.where('key ilike ?', "%#{params[:q]}%") builder = builder.order(id: :desc) @pagy, @stop_words = pagy(builder) end private def set_stop_word @stop_word = StopWord.find(params[:id]) end def stop_word_scope StopWord end def stop_word_params params.require(:stop_word).permit(:key, :user_id, :ugc, :username, :signature, :dialog, :nickname, :replacement) end end end
Version data entries
5 entries across 5 versions & 1 rubygems