Sha256: 95e4abb38b39b976e9a5566714e77c44e33b199136b17a45ad509f9cb8cdeab2

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

class ClientsController < ApplicationController
  before_action :set_client, only: [:show, :edit, :update, :destroy]

  autocomplete :client, :name

  def temp_autocomplete_client_name
    a = [["123","First"],["456","Second"], ["3", "Third"]]
    render :json => a.to_json
  end

  # GET /clients
  def index
    @clients = Client.all
  end

  # GET /clients/1
  def show
  end

  # GET /clients/new
  def new
    @client = Client.new
  end

  # GET /clients/1/edit
  def edit
  end

  # POST /clients
  def create
    @client = Client.new(client_params)

    if @client.save
      redirect_to @client, notice: 'Client was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /clients/1
  def update
    if @client.update(client_params)
      redirect_to @client, notice: 'Client was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /clients/1
  def destroy
    @client.destroy
    redirect_to clients_url, notice: 'Client was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_client
      @client = Client.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def client_params
      params[:client].permit(:name)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap3_autocomplete_input-0.1.9 test/dummy/app/controllers/clients_controller.rb
bootstrap3_autocomplete_input-0.1.8 test/dummy/app/controllers/clients_controller.rb