summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-21 22:57:51 -0700
committermo khan <mo@mokhan.ca>2014-02-21 22:57:51 -0700
commit33cb4e479decb1f7e15048b8c81924fe7498aec1 (patch)
tree0ce2c2e506e95fa2d1146e9b5505f0d718529bae /app
parentbf5c3435155c0ee9c2172bea6b6b3c5dec2c2463 (diff)
create users table and save applicant with the license.
Diffstat (limited to 'app')
-rw-r--r--app/models/license.rb1
-rw-r--r--app/models/user.rb10
2 files changed, 4 insertions, 7 deletions
diff --git a/app/models/license.rb b/app/models/license.rb
index ccf9b23..6170683 100644
--- a/app/models/license.rb
+++ b/app/models/license.rb
@@ -2,6 +2,7 @@ class License < ActiveRecord::Base
belongs_to :company
belongs_to :well_type
has_one :location
+ belongs_to :applicant, class_name: 'User', foreign_key: 'user_id'
def self.most_recent(page: 1, per_page: 10)
offset = (page - 1) * per_page
diff --git a/app/models/user.rb b/app/models/user.rb
index f2197dd..446d3e2 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,16 +1,12 @@
-class User
- attr_reader :company
-
- def initialize(company: nil)
- @company = company
- end
+class User < ActiveRecord::Base
+ belongs_to :company
def apply_for(well_type, location)
license = License.new
license.company = company
license.well_type = well_type
license.location = location
- #license.applicant = self
+ license.applicant = self
license.save!
license
end