Add Image class and migrations and such
parent
b12956db1e
commit
93aeee43ec
|
@ -0,0 +1,14 @@
|
|||
class Image < ApplicationRecord
|
||||
has_attached_file :attachment,
|
||||
# default_url: "/images/:style/missing.png",
|
||||
styles: { x1280: "1280x1280>",
|
||||
x640: "640x640>",
|
||||
x320: "320x320>",
|
||||
x160: "160x160>",
|
||||
x80: "80x80>" },
|
||||
size: { in: 0..5.megabytes } # Worst case scenario for 1280x1280 BMP.
|
||||
validates_attachment_content_type :attachment, content_type: /\Aimage\/.*\z/
|
||||
validates_attachment_file_name :attachment, matches: [/png\z/,
|
||||
/jpe?g\z/,
|
||||
/bmp\z/]
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class CreateImages < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :images do |t|
|
||||
t.timestamps
|
||||
end
|
||||
add_attachment :images, :attachment
|
||||
end
|
||||
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161207195423) do
|
||||
ActiveRecord::Schema.define(version: 20170111035209) do
|
||||
|
||||
create_table "delayed_jobs", force: :cascade do |t|
|
||||
t.integer "priority", default: 0, null: false
|
||||
|
@ -34,6 +34,15 @@ ActiveRecord::Schema.define(version: 20161207195423) do
|
|||
t.integer "max_log_count", default: 100
|
||||
end
|
||||
|
||||
create_table "images", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "attachment_file_name"
|
||||
t.string "attachment_content_type"
|
||||
t.integer "attachment_file_size"
|
||||
t.datetime "attachment_updated_at"
|
||||
end
|
||||
|
||||
create_table "logs", force: :cascade do |t|
|
||||
t.text "message"
|
||||
t.text "meta"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
factory :image do
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Image, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
# require 'rails_helper'
|
||||
|
||||
# RSpec.describe TokenExpiration, type: :model do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
# end
|
Loading…
Reference in New Issue