Skip to content

Commit 0edc6c1

Browse files
committed
#5 Move paperclip settings to configs
1 parent e033910 commit 0edc6c1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

app/models/kebapage/medium.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module Kebapage
22
class Medium < ActiveRecord::Base
33
has_attached_file :attachment,
4-
:styles => { large: '640x480#', thumb: '320x240#' },
5-
:url => '/system/kebapage/foto_:id.:extension',
6-
:path => ':rails_root/public:url'
4+
:styles => Rails.configuration.kebapage.attachment_styles,
5+
:url => Rails.configuration.kebapage.attachment_url,
6+
:path => Rails.configuration.kebapage.attachment_path
77

8-
validates_attachment_size :attachment, :less_than => 0..512.kilobytes
9-
validates_attachment_content_type :attachment, :content_type => %w(image/jpeg image/jpg image/png application/pdf)
8+
validates_attachment_size :attachment, :less_than => Rails.configuration.kebapage.attachment_max_size
9+
validates_attachment_content_type :attachment, :content_type => Rails.configuration.kebapage.attachment_content_type
1010

1111
Paperclip.interpolates :uniq_file_name do |attachment, style|
1212
attachment.instance.uniq_file_name

lib/kebapage/engine.rb

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ class Engine < ::Rails::Engine
77
config.after_initialize do
88
config.kebapage.front_layout = 'application'
99
config.kebapage.admin_layout = 'hq/application'
10+
config.kebapage.attachment_styles = { :large => '640x480#', :thumb => '320x240#' }
11+
config.kebapage.attachment_url = '/system/kebapage/foto_:id.:extension'
12+
config.kebapage.attachment_path = ':rails_root/public:url'
13+
config.kebapage.attachment_max_size = 0..512.kilobytes
14+
config.kebapage.attachment_content_type = %w(image/jpeg image/jpg image/png application/pdf)
1015
end
1116
end
1217
end

0 commit comments

Comments
 (0)