mirror of
https://github.com/fspc/bike-database.git
synced 2026-09-16 08:31:39 -04:00
lk | changes way application date is stored in db
This commit is contained in:
@@ -23,14 +23,12 @@ class ClientsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
if @client.update(client_params)
|
||||
@client.update(client_params)
|
||||
if @client.save
|
||||
notice = 'Client was successfully updated.'
|
||||
unless @client.bike.update_attribute(:date_sold, @client.pickup_date)
|
||||
notice = "Unable to update client's bike sale date"
|
||||
end
|
||||
redirect_to edit_client_url(@client), notice: notice
|
||||
redirect_to edit_client_url(@client), notice: "Client updated"
|
||||
else
|
||||
render action: 'edit'
|
||||
render action: 'edit', notice: "Unable to update client"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,6 +38,7 @@ class ClientsController < ApplicationController
|
||||
end
|
||||
|
||||
def client_params
|
||||
params["client"]["application_date"] = Date.strptime(params["client"]["application_date"], '%m/%d/%Y')
|
||||
params.require(:client).permit(
|
||||
:first_name,
|
||||
:last_name,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
.form-group
|
||||
= f.label "Application Date:", class: "col-sm-2 control-label"
|
||||
.col-sm-10
|
||||
= f.text_field :application_date, class: "form-control datepicker", disabled: disabled
|
||||
= f.text_field :application_date, value: @client.application_date && @client.application_date.strftime('%m/%d/%Y'), class: "form-control datepicker", disabled: disabled
|
||||
|
||||
.form-group
|
||||
= f.label "Agency:", class: "col-sm-2 control-label"
|
||||
|
||||
Reference in New Issue
Block a user