Skip to content

Commit e033910

Browse files
committed
#5 Set paperclip settings
1 parent 60e95a8 commit e033910

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

Gemfile.lock

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PATH
88
haml (~> 4.0.2)
99
haml-rails (~> 0.5.3)
1010
i18n (~> 0.6.9)
11+
paperclip
1112
rails (~> 4.0.2)
1213
rails-i18n (~> 4.0.1)
1314
simple_form (~> 3.0.1)
@@ -44,6 +45,10 @@ GEM
4445
bootstrap-wysihtml5-rails (0.3.1.23)
4546
railties (>= 3.0)
4647
builder (3.1.4)
48+
climate_control (0.0.3)
49+
activesupport (>= 3.0)
50+
cocaine (0.5.3)
51+
climate_control (>= 0.0.3, < 1.0)
4752
dropzonejs-rails (0.4.12)
4853
rails (> 3.1)
4954
erubis (2.7.0)
@@ -64,6 +69,11 @@ GEM
6469
mime-types (1.25.1)
6570
minitest (4.7.5)
6671
multi_json (1.8.4)
72+
paperclip (3.5.2)
73+
activemodel (>= 3.0.0)
74+
activesupport (>= 3.0.0)
75+
cocaine (~> 0.5.3)
76+
mime-types
6777
polyglot (0.3.3)
6878
rack (1.5.2)
6979
rack-test (0.6.2)

app/models/kebapage/medium.rb

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
module Kebapage
22
class Medium < ActiveRecord::Base
3-
has_attached_file :attachment, use_timestamp: false
3+
has_attached_file :attachment,
4+
:styles => { large: '640x480#', thumb: '320x240#' },
5+
:url => '/system/kebapage/foto_:id.:extension',
6+
:path => ':rails_root/public:url'
47

5-
validates_attachment_size :attachment, less_than: 5.megabytes
6-
validates_attachment_content_type :attachment, content_type: ['image/jpeg', 'image/png', 'application/pdf']
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)
10+
11+
Paperclip.interpolates :uniq_file_name do |attachment, style|
12+
attachment.instance.uniq_file_name
13+
end
14+
15+
def uniq_file_name
16+
Digest::SHA1.hexdigest(id.to_s)
17+
end
718
end
819
end

kebapage.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
2424
s.add_dependency 'bootstrap-wysihtml5-rails', '~> 0.3.1.23'
2525
s.add_dependency 'dropzonejs-rails', '0.4.12'
2626
s.add_dependency 'simple_form', '~> 3.0.1'
27+
s.add_dependency 'paperclip'
2728

2829
s.add_development_dependency 'sqlite3', '~> 1.3.8'
2930
end

lib/kebapage.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require "friendly_id"
33
require "bootstrap-wysihtml5-rails"
44
require "dropzonejs-rails"
5+
require "paperclip"
56

67
module Kebapage
78
end

0 commit comments

Comments
 (0)