mirror of
https://github.com/fspc/bike-database.git
synced 2026-09-16 08:31:39 -04:00
Louis | Adds clients model & views to db
This commit is contained in:
@@ -50,12 +50,24 @@ class BikesController < ApplicationController
|
||||
end
|
||||
|
||||
def bike_params
|
||||
params.require(:bike).permit(:entry_date, :brand, :model,
|
||||
:type, :color, :frame_size,
|
||||
:log_number, :purpose, :serial_number,
|
||||
:notes, :tag_info, :mechanic,
|
||||
:completion_date, :price,
|
||||
:top_tube_size, :seat_tube_size,
|
||||
:created_at, :updated_at)
|
||||
params.require(:bike).permit(
|
||||
:entry_date,
|
||||
:brand,
|
||||
:model,
|
||||
:type,
|
||||
:color,
|
||||
:frame_size,
|
||||
:log_number,
|
||||
:purpose,
|
||||
:serial_number,
|
||||
:notes,
|
||||
:tag_info,
|
||||
:mechanic,
|
||||
:completion_date,
|
||||
:price,
|
||||
:top_tube_size,
|
||||
:seat_tube_size,
|
||||
:created_at,
|
||||
:updated_at)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
class ClientsController < ApplicationController
|
||||
before_action :set_client, only: [:show, :edit, :update, :destroy]
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@clients = Client.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@client = Client.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@client = Client.new(client_params)
|
||||
respond_to do |format|
|
||||
if @client.save
|
||||
format.html { redirect_to @client, notice: 'Client was successfully created.' }
|
||||
else
|
||||
format.html { render action: 'new' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @client.update(client_params)
|
||||
format.html { redirect_to @client, notice: 'Client was successfully updated.' }
|
||||
else
|
||||
format.html { render action: 'edit' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@client.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to clients_url }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def set_client
|
||||
@client = Client.find(params[:id])
|
||||
end
|
||||
|
||||
def client_params
|
||||
params.require(:client).permit(
|
||||
:first_name,
|
||||
:last_name,
|
||||
:application_date,
|
||||
:gender,
|
||||
:age,
|
||||
:weight,
|
||||
:helmet,
|
||||
:lock,
|
||||
:agency,
|
||||
:completion_date)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user