Migrate Paperclip → has_local_attached in Image, News, Quote models
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
module Cmtool
|
||||
class Image
|
||||
include SimplyCouch::Model
|
||||
include Paperclip::Glue
|
||||
# TODO: Replace Paperclip with SimplyCouch::HasAttachment
|
||||
# 1. Change `include Paperclip::Glue` to `include SimplyCouch::HasAttachment`
|
||||
# 2. Replace `has_attached_file :file, styles: {...}` with `has_attachment :file, styles: {...}`
|
||||
# 3. Replace `validates_attachment` with standard Rails validations
|
||||
|
||||
property :file_file_name
|
||||
property :file_content_type
|
||||
property :file_file_size, type: Integer
|
||||
property :file_updated_at, type: Time
|
||||
has_attached_file :file, styles: { page: '728x10000>', medium: "354x1000>", thumb: "160x1250>" },
|
||||
path: ":rails_root/public/system/:attachment/:id/:style.:extension",
|
||||
url: "/system/:attachment/:id/:style.:extension"
|
||||
validates_attachment :file, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
|
||||
# Paperclip → has_local_attached migration
|
||||
has_local_attached :file,
|
||||
styles: { page: '728x10000>', medium: '354x1000>', thumb: '160x1250>' },
|
||||
content_type: %w[image/jpeg image/gif image/png]
|
||||
validates :file_file_name, presence: true
|
||||
|
||||
belongs_to :directory
|
||||
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
module Cmtool
|
||||
class News
|
||||
include SimplyCouch::Model
|
||||
include Paperclip::Glue
|
||||
# TODO: Replace Paperclip with SimplyCouch::HasAttachment
|
||||
# 1. Change `include Paperclip::Glue` to `include SimplyCouch::HasAttachment`
|
||||
# 2. Replace `has_attached_file :image, styles: {...}` with `has_attachment :image, styles: {...}`
|
||||
|
||||
property :title
|
||||
property :active, type: :boolean, default: true
|
||||
property :date, type: Date
|
||||
property :body
|
||||
|
||||
property :image_file_name
|
||||
property :image_content_type
|
||||
property :image_file_size, type: Integer
|
||||
property :image_updated_at, type: Time
|
||||
|
||||
has_attached_file :image, styles: { :medium => "500x500>", :thumb => "250x250>" }
|
||||
# Paperclip → has_local_attached migration
|
||||
has_local_attached :image,
|
||||
styles: { medium: '500x500>', thumb: '250x250>' }
|
||||
has_and_belongs_to_many :keywords, storing_keys: true
|
||||
validates :title, presence: true
|
||||
validates :date, presence: true
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
module Cmtool
|
||||
class Quote
|
||||
include SimplyCouch::Model
|
||||
include Paperclip::Glue
|
||||
# TODO: Replace Paperclip with SimplyCouch::HasAttachment
|
||||
# 1. Change `include Paperclip::Glue` to `include SimplyCouch::HasAttachment`
|
||||
# 2. Replace `has_attached_file :image, styles: {...}` with `has_attachment :image, styles: {...}`
|
||||
|
||||
property :owner
|
||||
property :function
|
||||
property :state
|
||||
@@ -13,12 +8,9 @@ module Cmtool
|
||||
property :active, type: :boolean, default: true
|
||||
property :locale
|
||||
|
||||
property :image_file_name
|
||||
property :image_content_type
|
||||
property :image_file_size, type: Integer
|
||||
property :image_updated_at, type: Time
|
||||
|
||||
has_attached_file :image, styles: {medium: "300x1000>", thumb: "137x1250>" }
|
||||
# Paperclip → has_local_attached migration
|
||||
has_local_attached :image,
|
||||
styles: { medium: '300x1000>', thumb: '137x1250>' }
|
||||
|
||||
view :for_sidebar_view, key: [:state, :created_at], conditions: %{doc['active']}
|
||||
STATES = %w[page sidebar]
|
||||
|
||||
Reference in New Issue
Block a user