Skip to content

Commit 7143410

Browse files
committed
Add Columns for profiles
age, attend_parties
1 parent 26409a3 commit 7143410

4 files changed

+25
-4
lines changed

app/models/profile.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ class Profile < ActiveRecord::Base
33

44
belongs_to :user
55

6-
attr_accessible :name, :phonetic_name, :blog, :hometown, :comment
6+
attr_accessible :name, :phonetic_name, :blog, :hometown, :comment, :age, :attend_parties
77

88
validates :name, :presence => true, :length => {:maximum => 60}
99
validates :phonetic_name, :length => {:maximum => 60}
1010
validates :blog, :length => {:maximum => 200}
1111
validates :comment, :length => {:maximum => 140}
12+
validates :age, :presence => true, :numericality => {:only_integer => true}
1213

1314
enumerize :hometown, :in => [
1415
:secret,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AddAgeColumnForProfile < ActiveRecord::Migration
2+
def up
3+
add_column :profiles, :age, :integer
4+
end
5+
6+
def down
7+
remove_column :profiles, :age
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AddAttendPartiesColumnForProfile < ActiveRecord::Migration
2+
def up
3+
add_column :profiles, :attend_parties, :boolean, :default => false
4+
end
5+
6+
def down
7+
remove_column :profiles, :attend_parties
8+
end
9+
end

db/schema.rb

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

14-
ActiveRecord::Schema.define(:version => 20120325055103) do
14+
ActiveRecord::Schema.define(:version => 20120325093444) do
1515

1616
create_table "profiles", :force => true do |t|
1717
t.integer "user_id"
@@ -21,8 +21,10 @@
2121
t.string "blog"
2222
t.string "hometown"
2323
t.text "comment"
24-
t.datetime "created_at", :null => false
25-
t.datetime "updated_at", :null => false
24+
t.datetime "created_at", :null => false
25+
t.datetime "updated_at", :null => false
26+
t.integer "age"
27+
t.boolean "attend_parties", :default => false
2628
end
2729

2830
add_index "profiles", ["user_id"], :name => "index_profiles_on_user_id"

0 commit comments

Comments
 (0)