Added carousel model
This commit is contained in:
parent
069cc0eb4c
commit
d9818f2749
6 changed files with 72 additions and 11 deletions
|
|
@ -31,7 +31,7 @@ class Conference < ActiveRecord::Base
|
||||||
has_many :vdays, :dependent => :destroy
|
has_many :vdays, :dependent => :destroy
|
||||||
has_many :vpositions, :dependent => :destroy
|
has_many :vpositions, :dependent => :destroy
|
||||||
has_many :vchoices, :dependent => :destroy
|
has_many :vchoices, :dependent => :destroy
|
||||||
|
has_many :photos, dependent: :destroy
|
||||||
belongs_to :venue
|
belongs_to :venue
|
||||||
|
|
||||||
accepts_nested_attributes_for :rooms, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true
|
accepts_nested_attributes_for :rooms, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true
|
||||||
|
|
|
||||||
11
app/models/photo.rb
Normal file
11
app/models/photo.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
class Photo < ActiveRecord::Base
|
||||||
|
attr_accessible :picture, :description
|
||||||
|
belongs_to :conference
|
||||||
|
validates_presence_of :picture
|
||||||
|
has_attached_file :picture,
|
||||||
|
styles: { thumb: '100x100>', large: '300x300>' }
|
||||||
|
|
||||||
|
validates_attachment_content_type :picture,
|
||||||
|
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||||
|
size: { in: 0..500.kilobytes }
|
||||||
|
end
|
||||||
13
db/migrate/20140610064046_create_photos.rb
Normal file
13
db/migrate/20140610064046_create_photos.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
class CreatePhotos < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :photos do |t|
|
||||||
|
t.text :description
|
||||||
|
t.string :picture_file_name
|
||||||
|
t.string :picture_content_type
|
||||||
|
t.integer :picture_file_size
|
||||||
|
t.datetime :picture_updated_at
|
||||||
|
t.belongs_to :conference
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
31
db/schema.rb
31
db/schema.rb
|
|
@ -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: 20140605125153) do
|
ActiveRecord::Schema.define(version: 20140610064046) do
|
||||||
|
|
||||||
create_table "answers", force: true do |t|
|
create_table "answers", force: true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|
@ -50,15 +50,15 @@ ActiveRecord::Schema.define(version: 20140605125153) do
|
||||||
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
|
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
|
||||||
|
|
||||||
create_table "conferences", force: true do |t|
|
create_table "conferences", force: true do |t|
|
||||||
t.string "guid", null: false
|
t.string "guid", null: false
|
||||||
t.string "title", null: false
|
t.string "title", null: false
|
||||||
t.string "short_title", null: false
|
t.string "short_title", null: false
|
||||||
t.string "social_tag"
|
t.string "social_tag"
|
||||||
t.string "contact_email", null: false
|
t.string "contact_email", null: false
|
||||||
t.string "timezone", null: false
|
t.string "timezone", null: false
|
||||||
t.string "html_export_path"
|
t.string "html_export_path"
|
||||||
t.date "start_date", null: false
|
t.date "start_date", null: false
|
||||||
t.date "end_date", null: false
|
t.date "end_date", null: false
|
||||||
t.integer "venue_id"
|
t.integer "venue_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
|
@ -209,6 +209,17 @@ ActiveRecord::Schema.define(version: 20140605125153) do
|
||||||
t.string "languages"
|
t.string "languages"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "photos", force: true do |t|
|
||||||
|
t.text "description"
|
||||||
|
t.string "picture_file_name"
|
||||||
|
t.string "picture_content_type"
|
||||||
|
t.integer "picture_file_size"
|
||||||
|
t.datetime "picture_updated_at"
|
||||||
|
t.integer "conference_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "qanswers", force: true do |t|
|
create_table "qanswers", force: true do |t|
|
||||||
t.integer "question_id"
|
t.integer "question_id"
|
||||||
t.integer "answer_id"
|
t.integer "answer_id"
|
||||||
|
|
@ -308,9 +319,9 @@ ActiveRecord::Schema.define(version: 20140605125153) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "tracks", force: true do |t|
|
create_table "tracks", force: true do |t|
|
||||||
t.string "guid", null: false
|
t.string "guid", null: false
|
||||||
t.integer "conference_id"
|
t.integer "conference_id"
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.string "color"
|
t.string "color"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
|
|
||||||
12
spec/factories/photos.rb
Normal file
12
spec/factories/photos.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :photo do
|
||||||
|
picture_file_name 'rails.png'
|
||||||
|
picture_content_type 'image/png'
|
||||||
|
picture_file_size '1024'
|
||||||
|
picture_updated_at DateTime.now
|
||||||
|
description 'Lorem Ipsum Dolor'
|
||||||
|
conference
|
||||||
|
end
|
||||||
|
end
|
||||||
14
spec/models/photo_spec.rb
Normal file
14
spec/models/photo_spec.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Photo do
|
||||||
|
describe 'validations' do
|
||||||
|
|
||||||
|
it 'has a valid factory' do
|
||||||
|
expect(build(:photo)).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'is not valid without a picture' do
|
||||||
|
should validate_presence_of(:picture)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue