From e731a6b58fe0d340a23413387f8aab1d0f96cf0d Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 20 Jun 2014 18:41:08 +0530 Subject: [PATCH] Adds migration for banner photo --- app/models/conference.rb | 14 ++++++++++---- ...0140620130306_add_banner_photo_to_conference.rb | 8 ++++++++ db/schema.rb | 8 ++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20140620130306_add_banner_photo_to_conference.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index 4816cf50..7eb14759 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -20,7 +20,7 @@ class Conference < ActiveRecord::Base :include_sponsors_in_splash, :include_tracks_in_splash, :include_tickets_in_splash, :include_social_media_in_splash, :include_program_in_splash, :make_conference_public, - :photos_attributes + :photos_attributes, :banner_photo has_paper_trail @@ -63,12 +63,18 @@ class Conference < ActiveRecord::Base accepts_nested_attributes_for :photos, allow_destroy: true has_attached_file :logo, - :styles => {:thumb => "100x100>", :large => "300x300>" } + styles: { thumb: '100x100>', large: '300x300>' } validates_attachment_content_type :logo, - :content_type => [/jpg/, /jpeg/, /png/, /gif/], - :size => { :in => 0..500.kilobytes } + content_type: [/jpg/, /jpeg/, /png/, /gif/], + size: { in: 0..500.kilobytes } + has_attached_file :banner_photo, + styles: { thumb: '100x100>', large: '1300x700>' } + + validates_attachment_content_type :banner_photo, + content_type: [/jpg/, /jpeg/, /png/, /gif/], + size: { in: 0..500.kilobytes } validates_presence_of :title, :short_title, :social_tag, diff --git a/db/migrate/20140620130306_add_banner_photo_to_conference.rb b/db/migrate/20140620130306_add_banner_photo_to_conference.rb new file mode 100644 index 00000000..37b66b6e --- /dev/null +++ b/db/migrate/20140620130306_add_banner_photo_to_conference.rb @@ -0,0 +1,8 @@ +class AddBannerPhotoToConference < ActiveRecord::Migration + def change + add_column :conferences, :banner_photo_file_name, :string + add_column :conferences, :banner_photo_content_type, :string + add_column :conferences, :banner_photo_file_size, :integer + add_column :conferences, :banner_photo_updated_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 71258bb0..90d0777c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140618062623) do +ActiveRecord::Schema.define(version: 20140620130306) do create_table "answers", force: true do |t| t.string "title" @@ -94,7 +94,11 @@ ActiveRecord::Schema.define(version: 20140618062623) do t.boolean "include_tickets_in_splash", default: false t.boolean "include_social_media_in_splash", default: false t.boolean "include_program_in_splash", default: false - t.boolean "make_conference_public", default: false + t.boolean "make_conference_public", default: false + t.string "banner_photo_file_name" + t.string "banner_photo_content_type" + t.integer "banner_photo_file_size" + t.datetime "banner_photo_updated_at" end create_table "conferences_questions", id: false, force: true do |t|