Adds photo to venue

This commit is contained in:
Gopesh Tulsyan 2014-06-14 18:33:39 +05:30
parent b94ee7e758
commit f5c5e6a44b
6 changed files with 24 additions and 2 deletions

View file

@ -1,8 +1,13 @@
class Venue < ActiveRecord::Base
attr_accessible :name, :description, :address, :website
attr_accessible :name, :description, :website, :address, :photo
has_many :conferences
before_create :generate_guid
has_attached_file :photo,
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :photo,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes }
private
def generate_guid

View file

@ -5,4 +5,7 @@
= f.input :address, :input_html => {:rows => 1}
= f.input :website
= f.input :description, :input_html => { :rows => 10, :cols => 20 }
- if !@venue.photo.blank?
= image_tag @venue.photo(:thumb)
= f.input :photo
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -0,0 +1,8 @@
class AddPhotoToVenue < ActiveRecord::Migration
def change
add_column :venues, :photo_file_name, :string
add_column :venues, :photo_content_type, :string
add_column :venues, :photo_file_size, :integer
add_column :venues, :photo_updated_at, :datetime
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140612181230) do
ActiveRecord::Schema.define(version: 20140613083115) do
create_table "answers", force: true do |t|
t.string "title"
@ -390,6 +390,10 @@ ActiveRecord::Schema.define(version: 20140612181230) do
t.string "offline_map_bounds"
t.datetime "created_at"
t.datetime "updated_at"
t.string "photo_file_name"
t.string "photo_content_type"
t.integer "photo_file_size"
t.datetime "photo_updated_at"
end
create_table "versions", force: true do |t|

View file

@ -9,5 +9,6 @@ FactoryGirl.define do
contact_email 'admin@example.com'
start_date Date.today
end_date Date.tomorrow
venue
end
end

View file

@ -4,5 +4,6 @@ FactoryGirl.define do
name 'Suse Office'
address 'Maxfeldstrasse 5 \n90409 Nuremberg'
website 'www.opensuse.org'
description 'Lorem Ipsum Dolor'
end
end