okay, so, we have associations rocking

This commit is contained in:
Ken Johnson
2013-05-24 19:15:36 -04:00
parent 0d841124f5
commit 471c5851c7
7 changed files with 51 additions and 5 deletions
+4
View File
@@ -0,0 +1,4 @@
class Retirement < ActiveRecord::Base
attr_accessible :employee_contrib, :employer_contrib, :total, :user_id
belongs_to :user
end
+3 -2
View File
@@ -10,7 +10,8 @@ class User < ActiveRecord::Base
validates_format_of :email, :with => /.+@.+\..+/i
attr_accessor :skip_user_id_assign
before_save :assign_user_id, :on => :create
has_one :retirement, :foreign_key => :user_id, :primary_key => :user_id
def self.authenticate(email, password)
@@ -28,7 +29,7 @@ class User < ActiveRecord::Base
end
return auth
end
def assign_user_id
unless @skip_user_id_assign.present?
user = User.order("user_id").last