mirror of
https://github.com/fspc/bike-database.git
synced 2025-02-23 09:33:23 -05:00
Louis | Allows users to associate clients with agencies
This commit is contained in:
parent
7ed3fce648
commit
2a33493ff2
@ -59,8 +59,8 @@ class ClientsController < ApplicationController
|
|||||||
:weight,
|
:weight,
|
||||||
:helmet,
|
:helmet,
|
||||||
:lock,
|
:lock,
|
||||||
:agency,
|
|
||||||
:completion_date,
|
:completion_date,
|
||||||
:bike_id)
|
:bike_id,
|
||||||
|
:agency_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
class Agency < ActiveRecord::Base
|
class Agency < ActiveRecord::Base
|
||||||
|
has_many :clients
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
class Client < ActiveRecord::Base
|
class Client < ActiveRecord::Base
|
||||||
has_one :bike
|
has_one :bike
|
||||||
|
belongs_to :agency
|
||||||
end
|
end
|
||||||
|
@ -50,11 +50,6 @@
|
|||||||
= f.label "Lock", class: "col-sm-2 control-label"
|
= f.label "Lock", class: "col-sm-2 control-label"
|
||||||
.col-sm-10
|
.col-sm-10
|
||||||
= f.check_box :lock, disabled: disabled
|
= f.check_box :lock, disabled: disabled
|
||||||
|
|
||||||
.form-group
|
|
||||||
= f.label "Agency", class: "col-sm-2 control-label"
|
|
||||||
.col-sm-10
|
|
||||||
= f.text_field :agency, class: "form-control", disabled: disabled
|
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label "Completion Date:", class: "col-sm-2 control-label"
|
= f.label "Completion Date:", class: "col-sm-2 control-label"
|
||||||
@ -66,3 +61,8 @@
|
|||||||
.col-sm-10
|
.col-sm-10
|
||||||
= f.select(:bike_id, Bike.all.collect {|b| [ b.name, b.id ] }, {include_blank: 'None'})
|
= f.select(:bike_id, Bike.all.collect {|b| [ b.name, b.id ] }, {include_blank: 'None'})
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label "Agency:", class: "col-sm-2 control-label"
|
||||||
|
.col-sm-10
|
||||||
|
= f.select(:agency_id, Agency.all.collect {|b| [ b.agency_name, b.id ] }, {include_blank: 'None'})
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
%tr
|
%tr
|
||||||
%td= client.first_name
|
%td= client.first_name
|
||||||
%td= client.last_name
|
%td= client.last_name
|
||||||
%td= client.agency
|
%td= client.agency.agency_name if client.agency
|
||||||
%td= link_to 'Show', client
|
%td= link_to 'Show', client
|
||||||
%td= link_to 'Edit', edit_client_path(client)
|
%td= link_to 'Edit', edit_client_path(client)
|
||||||
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' }
|
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' }
|
||||||
|
5
db/migrate/20140922232527_add_agency_to_client.rb
Normal file
5
db/migrate/20140922232527_add_agency_to_client.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddAgencyToClient < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_reference :clients, :agency, index: true
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class RemoveAgencyStringFromClient < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :clients, :agency
|
||||||
|
end
|
||||||
|
end
|
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140921225115) do
|
ActiveRecord::Schema.define(version: 20140922233036) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -60,15 +60,16 @@ ActiveRecord::Schema.define(version: 20140921225115) do
|
|||||||
t.integer "weight"
|
t.integer "weight"
|
||||||
t.boolean "helmet"
|
t.boolean "helmet"
|
||||||
t.boolean "lock"
|
t.boolean "lock"
|
||||||
t.string "agency"
|
|
||||||
t.date "completion_date"
|
t.date "completion_date"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "bike_id"
|
t.integer "bike_id"
|
||||||
t.string "bike_type_requested"
|
t.string "bike_type_requested"
|
||||||
t.boolean "will_pay"
|
t.boolean "will_pay"
|
||||||
|
t.integer "agency_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "clients", ["agency_id"], name: "index_clients_on_agency_id", using: :btree
|
||||||
add_index "clients", ["bike_id"], name: "index_clients_on_bike_id", using: :btree
|
add_index "clients", ["bike_id"], name: "index_clients_on_bike_id", using: :btree
|
||||||
|
|
||||||
create_table "users", force: true do |t|
|
create_table "users", force: true do |t|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user