[#347] update paperclip gem; change file validations
This commit is contained in:
parent
a35448a210
commit
2bcf8c39f3
2
Gemfile
2
Gemfile
|
@ -14,7 +14,7 @@ gem 'omniauth-github'
|
||||||
gem 'cancan', '1.6.7' # 1.6.8 fail specs with strange error
|
gem 'cancan', '1.6.7' # 1.6.8 fail specs with strange error
|
||||||
|
|
||||||
gem 'ancestry', '~> 1.3.0'
|
gem 'ancestry', '~> 1.3.0'
|
||||||
gem 'paperclip', '~> 3.3.1'
|
gem 'paperclip', '~> 4.1.0'
|
||||||
gem 'resque', '~> 1.24'
|
gem 'resque', '~> 1.24'
|
||||||
gem 'resque-status', '~> 0.3.3'
|
gem 'resque-status', '~> 0.3.3'
|
||||||
gem 'resque_mailer', '~> 2.2'
|
gem 'resque_mailer', '~> 2.2'
|
||||||
|
|
12
Gemfile.lock
12
Gemfile.lock
|
@ -88,7 +88,10 @@ GEM
|
||||||
charlock_holmes (0.6.9.4)
|
charlock_holmes (0.6.9.4)
|
||||||
chronic (0.10.2)
|
chronic (0.10.2)
|
||||||
chunky_png (1.2.9)
|
chunky_png (1.2.9)
|
||||||
cocaine (0.4.2)
|
climate_control (0.0.3)
|
||||||
|
activesupport (>= 3.0)
|
||||||
|
cocaine (0.5.3)
|
||||||
|
climate_control (>= 0.0.3, < 1.0)
|
||||||
coderay (1.1.0)
|
coderay (1.1.0)
|
||||||
coffee-rails (3.2.2)
|
coffee-rails (3.2.2)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
|
@ -253,11 +256,10 @@ GEM
|
||||||
oauth2 (~> 0.8.0)
|
oauth2 (~> 0.8.0)
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
paperclip (3.3.1)
|
paperclip (4.1.0)
|
||||||
activemodel (>= 3.0.0)
|
activemodel (>= 3.0.0)
|
||||||
activerecord (>= 3.0.0)
|
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
cocaine (~> 0.4.0)
|
cocaine (~> 0.5.3)
|
||||||
mime-types
|
mime-types
|
||||||
perform_later (1.3.0)
|
perform_later (1.3.0)
|
||||||
rails (~> 3.0)
|
rails (~> 3.0)
|
||||||
|
@ -492,7 +494,7 @@ DEPENDENCIES
|
||||||
omniauth-facebook
|
omniauth-facebook
|
||||||
omniauth-github
|
omniauth-github
|
||||||
omniauth-google-oauth2
|
omniauth-google-oauth2
|
||||||
paperclip (~> 3.3.1)
|
paperclip (~> 4.1.0)
|
||||||
perform_later (~> 1.3.0)
|
perform_later (~> 1.3.0)
|
||||||
pg (~> 0.14.0)
|
pg (~> 0.14.0)
|
||||||
puma
|
puma
|
||||||
|
|
|
@ -11,6 +11,8 @@ class Avatar < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
has_attached_file :avatar, styles: AVATAR_SIZES_HASH
|
has_attached_file :avatar, styles: AVATAR_SIZES_HASH
|
||||||
validates_inclusion_of :avatar_file_size, in: (0..MAX_AVATAR_SIZE), allow_nil: true
|
validates_inclusion_of :avatar_file_size, in: (0..MAX_AVATAR_SIZE), allow_nil: true
|
||||||
|
validates_attachment_content_type :avatar, content_type: /\Aimage/
|
||||||
|
validates_attachment_file_name :avatar, matches: [ /png\z/i, /png\z/i, /jpe?g\z/i, /gif\z/i, /bmp\z/i, /tif?f\z/i ]
|
||||||
|
|
||||||
attr_accessible :avatar
|
attr_accessible :avatar
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,10 @@ module Modules
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
validates_attachment_size :srpm, less_than: 500.megabytes
|
|
||||||
validates_attachment_content_type :srpm, content_type: ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], message: I18n.t('layout.invalid_content_type')
|
|
||||||
|
|
||||||
has_attached_file :srpm
|
has_attached_file :srpm
|
||||||
# attr_accessible :srpm
|
|
||||||
|
validates_attachment :srpm, size: { in: 0..500.megabytes }
|
||||||
|
validates_attachment_content_type :srpm, content_type: ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], message: I18n.t('layout.invalid_content_type')
|
||||||
|
|
||||||
after_create :create_git_repo
|
after_create :create_git_repo
|
||||||
after_commit(on: :create) {|p| p.fork_git_repo unless p.is_root?} # later with resque
|
after_commit(on: :create) {|p| p.fork_git_repo unless p.is_root?} # later with resque
|
||||||
|
|
Loading…
Reference in New Issue