class ClientsController < ApplicationController def index @clients = Client.where(user_id: current_user.id) end def new @client = Client.new end def create @client = Client.new(client_params) @client.user_id = current_user.id if @client.save redirect_to clients_path else render :new end end def edit @client = Client.find(params[:id]) end def update @client = Client.find(params[:id]) @client.user_id = current_user.id if @client.update(client_params) redirect_to clients_path else render 'edit' end end def destroy @client = Client.find(params[:id]) @client.destroy unless @client.blank? redirect_to clients_path end private def client_params params.require(:client).permit(:name, :description) end end