parent
80d901f666
commit
7850a2e6f0
@ -1,11 +0,0 @@
|
||||
class UserExtension < ActiveRecord::Base
|
||||
attr_accessible :birthday, :brief_introduction, :fans_num, :finish_project_num, :follow_num, :gender, :good_num, :location, :occupation, :publish_requirement_num, :user_id, :work_experience, :zip_code
|
||||
|
||||
belongs_to :user
|
||||
validate :validate_user
|
||||
|
||||
def validate_user
|
||||
errors.add :user_id, :invalid if user.nil? || !user.active? || User.current != user_id
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
class UserExtensions < ActiveRecord::Base
|
||||
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
|
||||
#this method was used to update the table user_extensions
|
||||
def update_user_extensions(birthday=nil,brief_introduction=nil,
|
||||
gender=nil,location=nil,occupation=nil,work_experience=nil,zip_code=nil)
|
||||
self.birthday = birthday
|
||||
self.brief_introduction = brief_introduction
|
||||
self.gender = gender
|
||||
self.location = location
|
||||
self.occupation = occupation
|
||||
self.work_experience = work_experience
|
||||
self.zip_code = zip_code
|
||||
self.save
|
||||
end
|
||||
|
||||
def get_brief_introduction
|
||||
return self.brief_introduction
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
class CreateUserExtensions < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :user_extensions do |t|
|
||||
t.column :user_id,:integer,:null => false
|
||||
t.column :birthday,:date
|
||||
t.column :brief_introduction,:string
|
||||
t.column :gender,:integer
|
||||
t.column :location,:string
|
||||
t.column :occupation,:string
|
||||
t.column :work_experience,:integer
|
||||
t.column :zip_code,:integer
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :user_extensions
|
||||
end
|
||||
end
|
Loading…
Reference in new issue