Skip to content

Commit 532b9fb

Browse files
committed
<cj> adding heroku, model relationships and playing with active admin
1 parent 3ec551b commit 532b9fb

10 files changed

+69
-14
lines changed

lender/Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ gem 'mechanize'
2626
gem 'shoulda'
2727

2828

29+
group :test, :development do
30+
gem "rspec-rails", "~> 2.4"
31+
end
32+
33+
2934
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
3035
# gem 'ruby-debug'
3136
# gem 'ruby-debug19', :require => 'ruby-debug'

lender/Gemfile.lock

+19-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ GEM
1515
rack-mount (~> 0.6.14)
1616
rack-test (~> 0.5.7)
1717
tzinfo (~> 0.3.23)
18-
activeadmin (0.2.1)
18+
activeadmin (0.2.2)
1919
devise (>= 1.1.2)
2020
formtastic (>= 1.1.0)
21-
haml (>= 3.0.18)
2221
inherited_views
2322
meta_search (>= 0.9.2)
2423
rails (>= 3.0.0)
24+
sass (>= 3.1.0)
2525
will_paginate (>= 3.0.pre2)
2626
activemodel (3.0.7)
2727
activesupport (= 3.0.7)
@@ -50,6 +50,7 @@ GEM
5050
bcrypt-ruby (~> 2.1.2)
5151
orm_adapter (~> 0.0.3)
5252
warden (~> 1.0.3)
53+
diff-lcs (1.1.2)
5354
erubis (2.6.6)
5455
abstract (>= 1.0.0)
5556
formtastic (1.2.3)
@@ -58,7 +59,7 @@ GEM
5859
i18n (~> 0.4)
5960
haml (3.1.1)
6061
has_scope (0.5.0)
61-
heroku (2.1.4)
62+
heroku (2.2.1)
6263
launchy (>= 0.3.2)
6364
rest-client (~> 1.6.1)
6465
term-ansicolor (~> 1.0.5)
@@ -124,7 +125,20 @@ GEM
124125
responders (0.6.4)
125126
rest-client (1.6.1)
126127
mime-types (>= 1.16)
127-
sass (3.1.1)
128+
rspec (2.6.0)
129+
rspec-core (~> 2.6.0)
130+
rspec-expectations (~> 2.6.0)
131+
rspec-mocks (~> 2.6.0)
132+
rspec-core (2.6.3)
133+
rspec-expectations (2.6.0)
134+
diff-lcs (~> 1.1.2)
135+
rspec-mocks (2.6.0)
136+
rspec-rails (2.6.1)
137+
actionpack (~> 3.0)
138+
activesupport (~> 3.0)
139+
railties (~> 3.0)
140+
rspec (~> 2.6.0)
141+
sass (3.1.2)
128142
shoulda (2.11.3)
129143
term-ansicolor (1.0.5)
130144
thor (0.14.6)
@@ -153,6 +167,7 @@ DEPENDENCIES
153167
oauth
154168
rails (= 3.0.7)
155169
rake (~> 0.8.7)
170+
rspec-rails (~> 2.4)
156171
sass
157172
shoulda
158173
unicorn

lender/app/admin/loans.rb

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
f.input :number_of_installments
77
f.input :emi
88
end
9+
f.input :customer
910
f.buttons
11+
# f.input :customer
12+
# f.buttons
1013
end
1114
end

lender/app/models/customer.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class Customer < ActiveRecord::Base
2+
has_many :loans
23
end

lender/app/models/loan.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
class Loan < ActiveRecord::Base
2+
belongs_to :customer
3+
has_one :vehicle
4+
5+
accepts_nested_attributes_for :customer
26
end

lender/app/models/vehicle.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class Vehicle < ActiveRecord::Base
2+
belongs_to :loan
23
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AddCustomerIdToLoan < ActiveRecord::Migration
2+
def self.up
3+
add_column :loans, :customer_id, :integer
4+
end
5+
6+
def self.down
7+
add_column :loans, :customer_id
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AddLoanIdToVehicle < ActiveRecord::Migration
2+
def self.up
3+
add_column :vehicles, :loan_id, :integer
4+
end
5+
6+
def self.down
7+
add_column :vehicles, :loan_id
8+
end
9+
end

lender/db/schema.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended to check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(:version => 20110526174326) do
13+
ActiveRecord::Schema.define(:version => 20110601105059) do
1414

1515
create_table "active_admin_comments", :force => true do |t|
1616
t.integer "resource_id", :null => false
@@ -60,6 +60,7 @@
6060
t.decimal "emi", :precision => 10, :scale => 0
6161
t.datetime "created_at"
6262
t.datetime "updated_at"
63+
t.integer "customer_id"
6364
end
6465

6566
create_table "vehicles", :force => true do |t|
@@ -73,6 +74,7 @@
7374
t.string "rto_agent"
7475
t.datetime "created_at"
7576
t.datetime "updated_at"
77+
t.integer "loan_id"
7678
end
7779

7880
end

lender/public/stylesheets/admin/active_admin.css

+15-9
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,13 @@ form {
439439
form fieldset > ol > li fieldset ol li {
440440
padding: 0;
441441
border: 0; }
442-
form input[type=text], form input[type=password], form input[type=email], form input[type=tel], form textarea {
442+
form input[type=text], form input[type=password], form input[type=email], form input[type=url], form input[type=tel], form textarea {
443443
width: 76%;
444444
border: 1px solid #c9d0d6;
445445
font-size: 0.95em;
446446
outline: none;
447447
padding: 8px 10px; }
448-
form input[type=text]:focus, form input[type=password]:focus, form input[type=email]:focus, form input[type=tel]:focus, form textarea:focus {
448+
form input[type=text]:focus, form input[type=password]:focus, form input[type=email]:focus, form input[type=url]:focus, form input[type=tel]:focus, form textarea:focus {
449449
border: 1px solid #99a2aa;
450450
box-shadow: 0 0 4px #99a2aa;
451451
-moz-box-shadow: 0 0 4px #99a2aa;
@@ -504,7 +504,7 @@ form {
504504
padding: 0;
505505
border: none;
506506
display: list-item; }
507-
form fieldset > ol > li.error input[type=text], form fieldset > ol > li.error input[type=password], form fieldset > ol > li.error input[type=email], form fieldset > ol > li.error input[type=tel], form fieldset > ol > li.error textarea {
507+
form fieldset > ol > li.error input[type=text], form fieldset > ol > li.error input[type=password], form fieldset > ol > li.error input[type=email], form fieldset > ol > li.error input[type=url], form fieldset > ol > li.error input[type=tel], form fieldset > ol > li.error textarea {
508508
border: 1px solid #cc0000; }
509509
form input[type=submit] {
510510
box-shadow: 0 1px 2px #aaaaaa;
@@ -782,17 +782,17 @@ body {
782782
#title_bar .action_items a:active {
783783
border: inherit; }
784784

785-
#content {
785+
#active_admin_content {
786786
margin: 0;
787787
padding: 25px 30px; }
788-
#content #main_content_wrapper {
788+
#active_admin_content #main_content_wrapper {
789789
float: left;
790790
width: 100%; }
791-
#content #main_content_wrapper #main_content {
791+
#active_admin_content #main_content_wrapper #main_content {
792792
margin-right: 300px; }
793-
#content.without_sidebar #main_content_wrapper #main_content {
793+
#active_admin_content.without_sidebar #main_content_wrapper #main_content {
794794
margin-right: 0; }
795-
#content #sidebar {
795+
#active_admin_content #sidebar {
796796
float: left;
797797
width: 270px;
798798
margin-left: -270px; }
@@ -1132,6 +1132,9 @@ table {
11321132
.pagination .previous_page, .pagination .next_page {
11331133
display: none; }
11341134

1135+
.index_content {
1136+
clear: both; }
1137+
11351138
table.index_grid td {
11361139
border: none;
11371140
background: none;
@@ -1218,7 +1221,7 @@ body.logged_out {
12181221
body.logged_out #content_wrapper {
12191222
width: 500px;
12201223
margin: 70px auto; }
1221-
body.logged_out #content_wrapper #content {
1224+
body.logged_out #content_wrapper #active_admin_content {
12221225
box-shadow: 0 1px 2px #aaaaaa;
12231226
-moz-box-shadow: 0 1px 2px #aaaaaa;
12241227
-webkit-box-shadow: 0 1px 2px #aaaaaa;
@@ -1357,6 +1360,9 @@ table.dashboard {
13571360
table.dashboard .dashboard_section > div {
13581361
padding: 3px 15px 15px 15px; }
13591362

1363+
.attributes_table {
1364+
overflow: hidden; }
1365+
13601366
.attributes_table table th, .attributes_table table td {
13611367
padding: 8px 12px 6px 12px;
13621368
vertical-align: top;

0 commit comments

Comments
 (0)