Skip to content

Instantly share code, notes, and snippets.

@gerep
Last active August 29, 2015 14:02
Show Gist options
  • Save gerep/0eca96975bf733c8424d to your computer and use it in GitHub Desktop.
Save gerep/0eca96975bf733c8424d to your computer and use it in GitHub Desktop.
%dl
%dt=label :file, I18n.t("activerecord.attributes.app.file_label")
%dd
=f.file_field :file
%small.block=form_field_message("app", "file", @version.errors[:file])
%dl
%dt=label :signature, I18n.t("activerecord.attributes.app.file_label")
%dd
=f.file_field :signature
%small.block=form_field_message("app", "signature", @version.errors[:signature])
=f.hidden_field :file_cache
=f.hidden_field :signature_cache
No such file or directory - /home/daniel/code/work/walk-manager-3/tmp/uploads/1403273353.829841.945.639/test1.posxml.pem
class FileUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage = :file
if Rails.env.test? or Rails.env.cucumber?
CarrierWave.configure do |config|
config.enable_processing = false
end
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"#{Rails.root}/tmp/uploads/#{DateTime.now.to_f}.#{rand(999)}.#{rand(999)}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :scale => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(wsxml)
end
# Override the filename of the uploaded files:
# def filename
# "something.jpg" if original_filename
# end
end
carrierwave-0.9.0
rails-3.2.16
ruby 2.0.0p481
class SignatureUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage = :file
if Rails.env.test? or Rails.env.cucumber?
CarrierWave.configure do |config|
config.enable_processing = false
end
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"#{Rails.root}/tmp/uploads/#{DateTime.now.to_f}.#{rand(999)}.#{rand(999)}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :scale => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(pem)
end
# Override the filename of the uploaded files:
# def filename
# "something.jpg" if original_filename
# end
end
class Version < ActiveRecord::Base
# ...
mount_uploader :file, FileUploader
mount_uploader :signature, SignatureUploader
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment