Skip to content

Commit e2208a4

Browse files
committed
Added avatar column to Profiles table
1 parent e0b6b6c commit e2208a4

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

saasapp/app/models/profile.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
class Profile < ActiveRecord::Base
22
belongs_to :user
3+
has_attached_file :avatar,
4+
styles: { medium: "300x300>", thumb: "100x100>" },
5+
default_url: "/images/:style/missing.png"
6+
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\z/
37
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddAttachmentAvatarToProfiles < ActiveRecord::Migration
2+
def self.up
3+
change_table :profiles do |t|
4+
t.attachment :avatar
5+
end
6+
end
7+
8+
def self.down
9+
remove_attachment :profiles, :avatar
10+
end
11+
end

saasapp/db/schema.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 20190524202239) do
13+
ActiveRecord::Schema.define(version: 20190624213405) do
1414

1515
create_table "contacts", force: :cascade do |t|
1616
t.string "name"
@@ -35,8 +35,12 @@
3535
t.string "phone_number"
3636
t.string "contact_email"
3737
t.text "description"
38-
t.datetime "created_at", null: false
39-
t.datetime "updated_at", null: false
38+
t.datetime "created_at", null: false
39+
t.datetime "updated_at", null: false
40+
t.string "avatar_file_name"
41+
t.string "avatar_content_type"
42+
t.integer "avatar_file_size"
43+
t.datetime "avatar_updated_at"
4044
end
4145

4246
create_table "users", force: :cascade do |t|

0 commit comments

Comments
 (0)