mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-21 02:07:49 +01:00
added profile_picture to users
This commit is contained in:
parent
f5917277fa
commit
cf3933271a
3 changed files with 34 additions and 16 deletions
|
@ -40,6 +40,9 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
# validates :website, format: { with: WEBSITE_REGEX }
|
# validates :website, format: { with: WEBSITE_REGEX }
|
||||||
|
|
||||||
|
has_attached_file :profile_picture, styles: { medium: "256x256>", thumb: "80x80>" }, default_url: "/images/:style/no_avatar.png"
|
||||||
|
validates_attachment_content_type :profile_picture, :content_type => /\Aimage\/.*\Z/
|
||||||
|
|
||||||
before_save do
|
before_save do
|
||||||
self.display_name = 'WRYYYYYYYY' if display_name == 'Dio Brando'
|
self.display_name = 'WRYYYYYYYY' if display_name == 'Dio Brando'
|
||||||
self.website = if website.match %r{\Ahttps?://}
|
self.website = if website.match %r{\Ahttps?://}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class AddAttachmentProfilePictureToUsers < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
change_table :users do |t|
|
||||||
|
t.attachment :profile_picture
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_attachment :users, :profile_picture
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20141228202825) do
|
ActiveRecord::Schema.define(version: 20141229085904) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -159,6 +159,10 @@ ActiveRecord::Schema.define(version: 20141228202825) do
|
||||||
t.string "location", default: "", null: false
|
t.string "location", default: "", null: false
|
||||||
t.text "bio", default: "", null: false
|
t.text "bio", default: "", null: false
|
||||||
t.boolean "moderator", default: false, null: false
|
t.boolean "moderator", default: false, null: false
|
||||||
|
t.string "profile_picture_file_name"
|
||||||
|
t.string "profile_picture_content_type"
|
||||||
|
t.integer "profile_picture_file_size"
|
||||||
|
t.datetime "profile_picture_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
||||||
|
|
Loading…
Reference in a new issue