Added Paperclip attachment handler
This commit is contained in:
parent
9ce7de03b1
commit
7aca36e46b
4 changed files with 30 additions and 6 deletions
3
Gemfile
3
Gemfile
|
|
@ -94,3 +94,6 @@ gem 'pg_search'
|
||||||
|
|
||||||
# Use SLIM as our templating language
|
# Use SLIM as our templating language
|
||||||
gem 'slim-rails'
|
gem 'slim-rails'
|
||||||
|
|
||||||
|
# Attachment/image handling
|
||||||
|
gem "paperclip", "~> 4.2"
|
||||||
|
|
|
||||||
10
Gemfile.lock
10
Gemfile.lock
|
|
@ -48,6 +48,10 @@ GEM
|
||||||
columnize (~> 0.8)
|
columnize (~> 0.8)
|
||||||
debugger-linecache (~> 1.2)
|
debugger-linecache (~> 1.2)
|
||||||
slop (~> 3.6)
|
slop (~> 3.6)
|
||||||
|
climate_control (0.0.3)
|
||||||
|
activesupport (>= 3.0)
|
||||||
|
cocaine (0.5.5)
|
||||||
|
climate_control (>= 0.0.3, < 1.0)
|
||||||
coderay (1.1.0)
|
coderay (1.1.0)
|
||||||
coffee-rails (4.1.0)
|
coffee-rails (4.1.0)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
|
|
@ -93,6 +97,11 @@ GEM
|
||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
nokogiri (1.6.5)
|
nokogiri (1.6.5)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
|
paperclip (4.2.1)
|
||||||
|
activemodel (>= 3.0.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
cocaine (~> 0.5.3)
|
||||||
|
mime-types
|
||||||
pg (0.17.1)
|
pg (0.17.1)
|
||||||
pg_search (0.7.8)
|
pg_search (0.7.8)
|
||||||
activerecord (>= 3.1)
|
activerecord (>= 3.1)
|
||||||
|
|
@ -189,6 +198,7 @@ DEPENDENCIES
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
jquery.fileupload-rails
|
jquery.fileupload-rails
|
||||||
|
paperclip (~> 4.2)
|
||||||
pg
|
pg
|
||||||
pg_search
|
pg_search
|
||||||
rails (= 4.2.0)
|
rails (= 4.2.0)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@ class Screenshot < ActiveRecord::Base
|
||||||
order('uploaddatetime DESC')
|
order('uploaddatetime DESC')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_attached_file :image,
|
||||||
|
styles: { :large => "800x600>", :thumb => "160x120>" },
|
||||||
|
default_url: "/images/dummy/no-screenshots-upload-one.svg"
|
||||||
|
#path: :rails_root/public/system/:class/:attachment/:id_partition/:style/:filename
|
||||||
|
validates_attachment_content_type :image, :content_type => /\Aimage\/png\Z/
|
||||||
|
|
||||||
def image_url(size)
|
def image_url(size)
|
||||||
"#{Rails.configuration.images_path_prefix}/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
|
"#{Rails.configuration.images_path_prefix}/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
17
db/schema.rb
17
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20141229173351) do
|
ActiveRecord::Schema.define(version: 20150103194230) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
@ -41,16 +41,21 @@ ActiveRecord::Schema.define(version: 20141229173351) do
|
||||||
|
|
||||||
create_table "screenshots", force: :cascade do |t|
|
create_table "screenshots", force: :cascade do |t|
|
||||||
t.integer "package_id"
|
t.integer "package_id"
|
||||||
t.string "version", limit: 50
|
t.string "version", limit: 50
|
||||||
t.datetime "uploaddatetime"
|
t.datetime "uploaddatetime"
|
||||||
t.string "uploaderhash", limit: 72
|
t.string "uploaderhash", limit: 72
|
||||||
t.string "uploaderip", limit: 15
|
t.string "uploaderip", limit: 15
|
||||||
t.boolean "approved"
|
t.boolean "approved"
|
||||||
t.boolean "markedfordelete"
|
t.boolean "markedfordelete"
|
||||||
t.string "delete_reason", limit: 100
|
t.string "delete_reason", limit: 100
|
||||||
t.string "description", limit: 40
|
t.string "description", limit: 40
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.string "image_file_name"
|
||||||
|
t.string "image_content_type"
|
||||||
|
t.integer "image_file_size"
|
||||||
|
t.datetime "image_updated_at"
|
||||||
|
t.string "image_fingerprint"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "screenshots", ["id", "approved"], name: "id_approved", using: :btree
|
add_index "screenshots", ["id", "approved"], name: "id_approved", using: :btree
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue