26 |
27 | h1. S3:
28 |
29 | Since this app stores files to amazon S3 you will need an "Amazon S3":http://aws.amazon.com/s3/ account, otherwise you can choose to store images on your local filesystem by editing the uploader:
30 |
31 |
32 |
33 | #app/uploaders/image_uploader.rb
34 | # Choose what kind of storage to use for this uploader:
35 | storage :file #stores files locally
36 | # storage :fog #stores files on S3
37 |
38 |
39 |
40 | Amazon S3 support is made possibile by "Fog":https://github.com/geemus/fog
41 |
42 | You will need to tell carrierwave to use Amazons S3 by creating an initializer and providing your Amazon S3 authentication details:
43 |
44 |
62 |
63 | h1. Image Processing:
64 |
65 | MiniMagick is app default for processing images; if you want to use another library, just edit the Gemfile and modify the uploader to reflect your choice:
66 |
67 |
68 |
69 | #app/uploaders/image_uploader.rb
70 | # Include RMagick or ImageScience support:
71 | # include CarrierWave::RMagick
72 | include CarrierWave::ImageScience
73 | # include CarrierWave::MiniMagick
74 |
75 |
76 |
77 | h1. References:
78 |
79 | * "carrierwave":https://github.com/jnicklas/carrierwave
80 |
81 | * "Jquery-File-Upload":https://github.com/blueimp/jQuery-File-Upload
82 |
83 | h1. TODO:
84 |
85 | * testing
86 |
87 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | # Add your own tasks in files placed in lib/tasks ending in .rake,
3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 |
5 | require File.expand_path('../config/application', __FILE__)
6 |
7 | CarrierwaveJqueryFileUpload::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/app/assets/images/spinner.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yortz/carrierwave_jquery_file_upload/85abe7a45c51f5dab2a2d476e8d997e778d3ff3c/app/assets/images/spinner.gif
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into including all the files listed below.
2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3 | // be included in the compiled file accessible from http://example.com/assets/application.js
4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5 | // the compiled file.
6 | //
7 | //= require jquery
8 | //= require jquery-ui
9 | //= require best_in_place
10 | //= require jquery.iframe-transport
11 | //= require jquery.fileupload
12 | //= require jquery.fileupload-ui
13 | //= require shadowbox
14 | //= require pictures/customupload
15 | //= require pictures/form
16 | //= require_tree .
--------------------------------------------------------------------------------
/app/assets/javascripts/pictures/customupload.js:
--------------------------------------------------------------------------------
1 | (function ($) {
2 | 'use strict';
3 |
4 | $.widget('blueimpUIX.fileupload', $.blueimpUI.fileupload, {
5 |
6 | options: {
7 | errorMessages: {
8 | maxFileSize: 'File is too big',
9 | minFileSize: 'File is too small',
10 | acceptFileTypes: 'Filetype not allowed',
11 | maxNumberOfFiles: 'Max number of files exceeded'
12 | }
13 | },
14 |
15 | _initFileUploadButtonBar: function () {
16 | var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
17 | filesList = this.element.find('.files'),
18 | ns = this.options.namespace;
19 | fileUploadButtonBar
20 | .addClass('ui-widget-header ui-corner-top');
21 | this.element.find('.fileinput-button').each(function () {
22 | var fileInput = $(this).find('input:file').detach();
23 | $(this).button({icons: {primary: 'ui-icon-plusthick'}})
24 | .append(fileInput);
25 | });
26 | fileUploadButtonBar.find('.start')
27 | .button({icons: {primary: 'ui-icon-circle-arrow-e'}})
28 | .bind('click.' + ns, function (e) {
29 | e.preventDefault();
30 | filesList.find('.start button').click();
31 | });
32 | fileUploadButtonBar.find('.cancel')
33 | .button({icons: {primary: 'ui-icon-cancel'}})
34 | .bind('click.' + ns, function (e) {
35 | e.preventDefault();
36 | filesList.find('.cancel button').click();
37 | });
38 | fileUploadButtonBar.find('.delete')
39 | .button({icons: {primary: 'ui-icon-trash'}})
40 | .bind('click.' + ns, function (e) {
41 | e.preventDefault();
42 | if (confirm("Are you sure you want to delete all files?")) {
43 | filesList.find('.delete').addClass("all");
44 | filesList.find('.all button').click();
45 | }
46 | else {
47 | return false;
48 | }
49 | });
50 | },
51 |
52 | _deleteHandler: function (e) {
53 | e.preventDefault();
54 | var button = $(this);
55 | if ($(this).parent().hasClass("all")) {
56 | e.data.fileupload._trigger('destroy', e, {
57 | context: button.closest('.template-download'),
58 | url: button.attr('data-url'),
59 | type: button.attr('data-type'),
60 | dataType: e.data.fileupload.options.dataType
61 | });
62 | }
63 | else {
64 | if ( confirm("Are you sure you want to delete this file ?") == true) {
65 | e.data.fileupload._trigger('destroy', e, {
66 | context: button.closest('.template-download'),
67 | url: button.attr('data-url'),
68 | type: button.attr('data-type'),
69 | dataType: e.data.fileupload.options.dataType
70 | });
71 | console.info($(this).parent());
72 | }
73 | else {
74 | return false;
75 | }
76 | }
77 | },
78 |
79 | _renderUploadTemplate: function (files) {
80 | var that = this,
81 | rows = $();
82 | $.each(files, function (index, file) {
83 | file = that._uploadTemplateHelper(file);
84 | var row = $('
' +
85 | '
' +
86 | '
' +
87 | '
' +
88 | (file.error ?
89 | '
'
90 | :
91 | '
' +
92 | '
'
93 | ) +
94 | '
' +
95 | '
');
96 | row.find('.name').text(file.name);
97 | row.find('.size').text(file.sizef);
98 | if (file.error) {
99 | row.addClass('ui-state-error');
100 | row.find('.error').text(
101 | that.options.errorMessages[file.error] || file.error
102 | );
103 | }
104 | rows = rows.add(row);
105 | });
106 | return rows;
107 | }
108 |
109 | });
110 |
111 | }(jQuery));
--------------------------------------------------------------------------------
/app/assets/javascripts/pictures/form.js:
--------------------------------------------------------------------------------
1 | $(function () {
2 |
3 | $('.fileupload-content').append('');
4 |
5 | var inputs = $('#new_picture :input[type=text]');
6 |
7 | clearFields(inputs);
8 |
9 | function clearFields (inputs) {
10 | $('.ui-state-error-text').remove();
11 | $.each(inputs, function(index, field){
12 | $(field).focus(function(){
13 | $(field).removeClass("ui-state-error");
14 | $(field).next().remove();
15 | });
16 | });
17 | };
18 |
19 | // Initialize the jQuery File Upload widget:
20 | $('#fileupload').fileupload({
21 | maxNumberOfFiles: 10,
22 | acceptFileTypes: /\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG)$/
23 | });
24 |
25 | //
26 | // Load existing files:
27 | $.getJSON($('#fileupload form').prop('action'), function (files) {
28 | var fu = $('#fileupload').data('fileupload');
29 | //fu._adjustMaxNumberOfFiles(-files.length);
30 | fu._renderDownload(files)
31 | .appendTo($('#fileupload .files'))
32 | .fadeIn(function () {
33 | // Fix for IE7 and lower:
34 | $(this).show();
35 | });
36 |
37 | $(".best_in_place").best_in_place();
38 | Shadowbox.init();
39 | $('#loading').hide();
40 | });
41 |
42 | // Open download dialogs via iframes,
43 | // to prevent aborting current uploads:
44 | $('#fileupload .files a:not([target^=_blank])').live('click', function (e) {
45 | e.preventDefault();
46 | $('')
47 | .prop('src', this.href)
48 | .appendTo('body');
49 | });
50 |
51 |
52 | $('#fileupload').bind('fileuploadsend', function (e, data) {
53 |
54 | var values = {};
55 |
56 | $.each($('#new_picture').serializeArray(), function(i, field) {
57 | values[field.name] = field.value;
58 | });
59 |
60 | var title = values["picture[title]"]
61 | var description = values["picture[description]"]
62 |
63 | $.each( values, function(k, v){
64 | if (v == 0) {
65 | $('input[name="' + k + '"]').addClass("ui-state-error");
66 | $('input[name="' + k + '"]').after(" can't be blank!");
67 | }
68 | });
69 |
70 | });
71 |
72 | $('#fileupload').bind('fileuploadprogressall', function (e,data) {
73 | var progress = parseInt(data.loaded / data.total * 100, 10);
74 | //$('.progress-bar').find('div').css('width', progress + '%').find('span').html(progress + '%');
75 | console.info(progress);
76 | });
77 |
78 | });
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory
3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4 | * the top of the compiled file, but it's generally better to create a new file per style scope.
5 | *= require_self
6 | *= require_tree .
7 | //= require jquery.fileupload-ui
8 | //= require nifty-layout
9 | //= require best_in_place
10 | //= require shadowbox
11 | */
12 |
13 | #loading {
14 | top: 50%;
15 | margin-bottom: 25px;
16 | margin-left: 45%;
17 | margin-right: 45%;
18 | width:128px;
19 | height:128px;
20 | background-image: url(../assets/spinner.gif);
21 | }
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 | end
4 |
--------------------------------------------------------------------------------
/app/controllers/pictures_controller.rb:
--------------------------------------------------------------------------------
1 | class PicturesController < ApplicationController
2 | # GET /pictures
3 | # GET /pictures.json
4 | def index
5 | @pictures = Picture.all
6 |
7 | respond_to do |format|
8 | format.html # index.html.erb
9 | format.json { render :json => @pictures.collect { |p| p.to_jq_upload }.to_json }
10 | end
11 | end
12 |
13 | # GET /pictures/1
14 | # GET /pictures/1.json
15 | def show
16 | @picture = Picture.find(params[:id])
17 |
18 | respond_to do |format|
19 | format.html # show.html.erb
20 | format.json { render json: @picture }
21 | end
22 | end
23 |
24 | # GET /pictures/new
25 | # GET /pictures/new.json
26 | def new
27 | @picture = Picture.new
28 |
29 | respond_to do |format|
30 | format.html # new.html.erb
31 | format.json { render json: @picture }
32 | end
33 | end
34 |
35 | # GET /pictures/1/edit
36 | def edit
37 | @picture = Picture.find(params[:id])
38 | end
39 |
40 | # POST /pictures
41 | # POST /pictures.json
42 | def create
43 | @picture = Picture.new(params[:picture])
44 |
45 | respond_to do |format|
46 | if @picture.save
47 | format.json { render :json => [ @picture.to_jq_upload ].to_json }
48 | else
49 | format.json { render :json => [ @picture.to_jq_upload.merge({ :error => "custom_failure" }) ].to_json }
50 | end
51 | end
52 | end
53 |
54 | # PUT /pictures/1
55 | # PUT /pictures/1.json
56 | def update
57 | @picture = Picture.find(params[:id])
58 |
59 | respond_to do |format|
60 | if @picture.update_attributes(params[:picture])
61 | format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }
62 | format.json { head :ok }
63 | else
64 | format.html { render action: "edit" }
65 | format.json { render json: @picture.errors, status: :unprocessable_entity }
66 | end
67 | end
68 | end
69 |
70 | # DELETE /pictures/1
71 | # DELETE /pictures/1.json
72 | def destroy
73 | @picture = Picture.find(params[:id])
74 | @picture.destroy
75 |
76 | respond_to do |format|
77 | format.html { redirect_to pictures_url }
78 | format.json { render :json => true }
79 | end
80 | end
81 | end
82 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/error_messages_helper.rb:
--------------------------------------------------------------------------------
1 | module ErrorMessagesHelper
2 | # Render error messages for the given objects. The :message and :header_message options are allowed.
3 | def error_messages_for(*objects)
4 | options = objects.extract_options!
5 | options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
6 | options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
7 | messages = objects.compact.map { |o| o.errors.full_messages }.flatten
8 | unless messages.empty?
9 | content_tag(:div, :class => "error_messages") do
10 | list_items = messages.map { |msg| content_tag(:li, msg) }
11 | content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
12 | end
13 | end
14 | end
15 |
16 | module FormBuilderAdditions
17 | def error_messages(options = {})
18 | @template.error_messages_for(@object, options)
19 | end
20 | end
21 | end
22 |
23 | ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
24 |
--------------------------------------------------------------------------------
/app/helpers/layout_helper.rb:
--------------------------------------------------------------------------------
1 | # These helper methods can be called in your template to set variables to be used in the layout
2 | # This module should be included in all views globally,
3 | # to do so you may need to add this line to your ApplicationController
4 | # helper :layout
5 | module LayoutHelper
6 | def title(page_title, show_title = true)
7 | content_for(:title) { h(page_title.to_s) }
8 | @show_title = show_title
9 | end
10 |
11 | def show_title?
12 | @show_title
13 | end
14 |
15 | def stylesheet(*args)
16 | content_for(:head) { stylesheet_link_tag(*args) }
17 | end
18 |
19 | def javascript(*args)
20 | content_for(:head) { javascript_include_tag(*args) }
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/app/helpers/pictures_helper.rb:
--------------------------------------------------------------------------------
1 | module PicturesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/mailers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yortz/carrierwave_jquery_file_upload/85abe7a45c51f5dab2a2d476e8d997e778d3ff3c/app/mailers/.gitkeep
--------------------------------------------------------------------------------
/app/models/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yortz/carrierwave_jquery_file_upload/85abe7a45c51f5dab2a2d476e8d997e778d3ff3c/app/models/.gitkeep
--------------------------------------------------------------------------------
/app/models/picture.rb:
--------------------------------------------------------------------------------
1 | class Picture < ActiveRecord::Base
2 | include Rails.application.routes.url_helpers
3 | validates_presence_of :title, :description, :file
4 | mount_uploader :file, ImageUploader
5 |
6 | #one convenient method to pass jq_upload the necessary information
7 | def to_jq_upload
8 | {
9 | "id" => read_attribute(:id),
10 | "title" => read_attribute(:title),
11 | "description" => read_attribute(:description),
12 | "name" => read_attribute(:file),
13 | "size" => file.size,
14 | "url" => file.url,
15 | "thumbnail_url" => file.thumb.url,
16 | "delete_url" => picture_path(:id => id),
17 | "delete_type" => "DELETE"
18 | }
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/app/uploaders/image_uploader.rb:
--------------------------------------------------------------------------------
1 | class ImageUploader < CarrierWave::Uploader::Base
2 |
3 | # Include RMagick or ImageScience support:
4 | # include CarrierWave::RMagick
5 | # include CarrierWave::ImageScience
6 | include CarrierWave::MiniMagick
7 |
8 | # Choose what kind of storage to use for this uploader:
9 | # storage :file
10 | storage :fog
11 |
12 | # Override the directory where uploaded files will be stored.
13 | # This is a sensible default for uploaders that are meant to be mounted:
14 | def store_dir
15 | "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
16 | end
17 |
18 | # Provide a default URL as a default if there hasn't been a file uploaded:
19 | # def default_url
20 | # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
21 | # end
22 |
23 | # Process files as they are uploaded:
24 | # process :scale => [200, 300]
25 | #
26 | # def scale(width, height)
27 | # # do something
28 | # end
29 |
30 | # Create different versions of your uploaded files:
31 | process :resize_to_fit => [800, 600]
32 |
33 | version :thumb do
34 | process :resize_to_fit => [80, 80]
35 | end
36 |
37 | version :medium do
38 | process :resize_to_fit => [200, 200]
39 | end
40 |
41 | # Add a white list of extensions which are allowed to be uploaded.
42 | # For images you might use something like this:
43 | def extension_white_list
44 | %w(jpg jpeg gif png)
45 | end
46 |
47 | # Override the filename of the uploaded files:
48 | # def filename
49 | # "something.jpg" if original_filename
50 | # end
51 |
52 | end
53 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%= content_for?(:title) ? yield(:title) : "jQuery-File-Upload" %>
5 | <%= stylesheet_link_tag "application" %>
6 | <%= javascript_include_tag :application %>
7 | <%= csrf_meta_tag %>
8 | <%= yield(:head) %>
9 |
10 |
11 |
17 |
18 |
19 | <%= link_to 'Edit', edit_picture_path(@picture) %> |
20 | <%= link_to 'Back', pictures_path %>
21 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run CarrierwaveJqueryFileUpload::Application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | # Pick the frameworks you want:
4 | require "active_record/railtie"
5 | require "action_controller/railtie"
6 | require "action_mailer/railtie"
7 | require "active_resource/railtie"
8 | require "sprockets/railtie"
9 | # require "rails/test_unit/railtie"
10 |
11 | if defined?(Bundler)
12 | # If you precompile assets before deploying to production, use this line
13 | Bundler.require(*Rails.groups(:assets => %w(development test)))
14 | # If you want your assets lazily compiled in production, use this line
15 | # Bundler.require(:default, :assets, Rails.env)
16 | end
17 |
18 | module CarrierwaveJqueryFileUpload
19 | class Application < Rails::Application
20 | # Settings in config/environments/* take precedence over those specified here.
21 | # Application configuration should go into files in config/initializers
22 | # -- all .rb files in that directory are automatically loaded.
23 |
24 | # Custom directories with classes and modules you want to be autoloadable.
25 | # config.autoload_paths += %W(#{config.root}/extras)
26 |
27 | # Only load the plugins named here, in the order given (default is alphabetical).
28 | # :all can be used as a placeholder for all plugins not explicitly named.
29 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
30 |
31 | # Activate observers that should always be running.
32 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33 |
34 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
36 | # config.time_zone = 'Central Time (US & Canada)'
37 |
38 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
40 | # config.i18n.default_locale = :de
41 |
42 | # Configure the default encoding used in templates for Ruby 1.9.
43 | config.encoding = "utf-8"
44 |
45 | # Configure sensitive parameters which will be filtered from the log file.
46 | config.filter_parameters += [:password]
47 |
48 | # Enable the asset pipeline
49 | config.assets.enabled = true
50 |
51 | # Version of your assets, change this if you want to expire all your assets
52 | config.assets.version = '1.0'
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 |
6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # MySQL. Versions 4.1 and 5.0 are recommended.
2 | #
3 | # Install the MYSQL driver
4 | # gem install mysql2
5 | #
6 | # Ensure the MySQL gem is defined in your Gemfile
7 | # gem 'mysql2'
8 | #
9 | # And be sure to use new-style password hashing:
10 | # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11 | development:
12 | adapter: mysql2
13 | encoding: utf8
14 | reconnect: false
15 | database: cjfu_development
16 | pool: 5
17 | username: root
18 | password:
19 | socket: /tmp/mysql.sock
20 |
21 | # Warning: The database defined as "test" will be erased and
22 | # re-generated from your development database when you run "rake".
23 | # Do not set this db to the same as development or production.
24 | test:
25 | adapter: mysql2
26 | encoding: utf8
27 | reconnect: false
28 | database: cjfu_test
29 | pool: 5
30 | username: root
31 | password:
32 | socket: /tmp/mysql.sock
33 |
34 | production:
35 | adapter: mysql2
36 | encoding: utf8
37 | reconnect: false
38 | database: cjfu_production
39 | pool: 5
40 | username: root
41 | password:
42 | socket: /tmp/mysql.sock
43 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | CarrierwaveJqueryFileUpload::Application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | CarrierwaveJqueryFileUpload::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger
20 | config.active_support.deprecation = :log
21 |
22 | # Only use best-standards-support built into browsers
23 | config.action_dispatch.best_standards_support = :builtin
24 |
25 | # Do not compress assets
26 | config.assets.compress = false
27 |
28 | # Expands the lines which load the assets
29 | config.assets.debug = true
30 | end
31 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | CarrierwaveJqueryFileUpload::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # Code is not reloaded between requests
5 | config.cache_classes = true
6 |
7 | # Full error reports are disabled and caching is turned on
8 | config.consider_all_requests_local = false
9 | config.action_controller.perform_caching = true
10 |
11 | # Disable Rails's static asset server (Apache or nginx will already do this)
12 | config.serve_static_assets = false
13 |
14 | # Compress JavaScripts and CSS
15 | config.assets.compress = true
16 |
17 | # Don't fallback to assets pipeline if a precompiled asset is missed
18 | config.assets.compile = false
19 |
20 | # Generate digests for assets URLs
21 | config.assets.digest = true
22 |
23 | # Defaults to Rails.root.join("public/assets")
24 | # config.assets.manifest = YOUR_PATH
25 |
26 | # Specifies the header that your server uses for sending files
27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29 |
30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31 | # config.force_ssl = true
32 |
33 | # See everything in the log (default is :info)
34 | # config.log_level = :debug
35 |
36 | # Use a different logger for distributed setups
37 | # config.logger = SyslogLogger.new
38 |
39 | # Use a different cache store in production
40 | # config.cache_store = :mem_cache_store
41 |
42 | # Enable serving of images, stylesheets, and JavaScripts from an asset server
43 | # config.action_controller.asset_host = "http://assets.example.com"
44 |
45 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46 | # config.assets.precompile += %w( search.js )
47 |
48 | # Disable delivery errors, bad email addresses will be ignored
49 | # config.action_mailer.raise_delivery_errors = false
50 |
51 | # Enable threaded mode
52 | # config.threadsafe!
53 |
54 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55 | # the I18n.default_locale when a translation can not be found)
56 | config.i18n.fallbacks = true
57 |
58 | # Send deprecation notices to registered listeners
59 | config.active_support.deprecation = :notify
60 | end
61 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | CarrierwaveJqueryFileUpload::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Configure static asset server for tests with Cache-Control for performance
11 | config.serve_static_assets = true
12 | config.static_cache_control = "public, max-age=3600"
13 |
14 | # Log error messages when you accidentally call methods on nil
15 | config.whiny_nils = true
16 |
17 | # Show full error reports and disable caching
18 | config.consider_all_requests_local = true
19 | config.action_controller.perform_caching = false
20 |
21 | # Raise exceptions instead of rendering exception templates
22 | config.action_dispatch.show_exceptions = false
23 |
24 | # Disable request forgery protection in test environment
25 | config.action_controller.allow_forgery_protection = false
26 |
27 | # Tell Action Mailer not to deliver emails to the real world.
28 | # The :test delivery method accumulates sent emails in the
29 | # ActionMailer::Base.deliveries array.
30 | config.action_mailer.delivery_method = :test
31 |
32 | # Use SQL instead of Active Record's schema dumper when creating the test database.
33 | # This is necessary if your schema can't be completely dumped by the schema dumper,
34 | # like if you have constraints or database-specific column types
35 | # config.active_record.schema_format = :sql
36 |
37 | # Print deprecation notices to the stderr
38 | config.active_support.deprecation = :stderr
39 | end
40 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | CarrierwaveJqueryFileUpload::Application.config.secret_token = '355e0206740db869b3c3e5deb928f128d701acd9e1b637e174e9f0bc68149ffa20e7a1927af97cc1ed5fb1015ef0d3b44352f5be5f914d647193ad4482587ad1'
8 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | CarrierwaveJqueryFileUpload::Application.config.session_store :cookie_store, key: '_carrierwave_jquery_file_upload_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # CarrierwaveJqueryFileUpload::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # Disable root element in JSON by default.
12 | ActiveSupport.on_load(:active_record) do
13 | self.include_root_in_json = false
14 | end
15 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | CarrierwaveJqueryFileUpload::Application.routes.draw do
2 | resources :pictures
3 | root :to => 'pictures#index'
4 |
5 | # The priority is based upon order of creation:
6 | # first created -> highest priority.
7 |
8 | # Sample of regular route:
9 | # match 'products/:id' => 'catalog#view'
10 | # Keep in mind you can assign values other than :controller and :action
11 |
12 | # Sample of named route:
13 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
14 | # This route can be invoked with purchase_url(:id => product.id)
15 |
16 | # Sample resource route (maps HTTP verbs to controller actions automatically):
17 | # resources :products
18 |
19 | # Sample resource route with options:
20 | # resources :products do
21 | # member do
22 | # get 'short'
23 | # post 'toggle'
24 | # end
25 | #
26 | # collection do
27 | # get 'sold'
28 | # end
29 | # end
30 |
31 | # Sample resource route with sub-resources:
32 | # resources :products do
33 | # resources :comments, :sales
34 | # resource :seller
35 | # end
36 |
37 | # Sample resource route with more complex sub-resources
38 | # resources :products do
39 | # resources :comments
40 | # resources :sales do
41 | # get 'recent', :on => :collection
42 | # end
43 | # end
44 |
45 | # Sample resource route within a namespace:
46 | # namespace :admin do
47 | # # Directs /admin/products/* to Admin::ProductsController
48 | # # (app/controllers/admin/products_controller.rb)
49 | # resources :products
50 | # end
51 |
52 | # You can have the root of your site routed with "root"
53 | # just remember to delete public/index.html.
54 | # root :to => 'welcome#index'
55 |
56 | # See how all your routes lay out with "rake routes"
57 |
58 | # This is a legacy wild controller route that's not recommended for RESTful applications.
59 | # Note: This route will make all actions in every controller accessible via GET requests.
60 | # match ':controller(/:action(/:id(.:format)))'
61 | end
62 |
--------------------------------------------------------------------------------
/db/migrate/20111021151343_create_pictures.rb:
--------------------------------------------------------------------------------
1 | class CreatePictures < ActiveRecord::Migration
2 | def change
3 | create_table :pictures do |t|
4 | t.string :title
5 | t.string :description
6 | t.string :file
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # encoding: UTF-8
2 | # This file is auto-generated from the current state of the database. Instead
3 | # of editing this file, please use the migrations feature of Active Record to
4 | # incrementally modify your database, and then regenerate this schema definition.
5 | #
6 | # Note that this schema.rb definition is the authoritative source for your
7 | # database schema. If you need to create the application database on another
8 | # system, you should be using db:schema:load, not running all the migrations
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 | # you'll amass, the slower it'll run and the greater likelihood for issues).
11 | #
12 | # It's strongly recommended to check this file into your version control system.
13 |
14 | ActiveRecord::Schema.define(:version => 20111021151343) do
15 |
16 | create_table "pictures", :force => true do |t|
17 | t.string "title"
18 | t.string "description"
19 | t.string "file"
20 | t.datetime "created_at"
21 | t.datetime "updated_at"
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
--------------------------------------------------------------------------------
/doc/README_FOR_APP:
--------------------------------------------------------------------------------
1 | Use this README file to introduce your application and point to useful places in the API for learning more.
2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
3 |
--------------------------------------------------------------------------------
/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yortz/carrierwave_jquery_file_upload/85abe7a45c51f5dab2a2d476e8d997e778d3ff3c/lib/assets/.gitkeep
--------------------------------------------------------------------------------
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yortz/carrierwave_jquery_file_upload/85abe7a45c51f5dab2a2d476e8d997e778d3ff3c/lib/tasks/.gitkeep
--------------------------------------------------------------------------------
/log/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yortz/carrierwave_jquery_file_upload/85abe7a45c51f5dab2a2d476e8d997e778d3ff3c/log/.gitkeep
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.