<commit_before># Uploads - Easy uploads for rails.

1. No predefined CSS and templates.
2. Support rails CSRF TOKEN.
3. No middleware, just your controllers.
4. Use as much as possible jQuery building functions.

## Installation

Add it to our Gemfile

```ruby
gem 'uploads'
```

## In your controller

```ruby
class UserUploadsController < ApplicationController
  # includes Uploads module for #respond_to_upload method
  include Uploads

  def create
    # create you Upload model as usual
    @upload = current_user.user_uploads.new
    
    respond_to_upload(request) do |file, response|
      # grab uploaded file
      @upload.image = file
      # try to save it
      if response[:success] = @upload.save
        # send back upload id and image preview
        response[:user_upload_id] = @upload.id
        response[:user_upload_preview_url] = @upload.image.url(:avator_editor)
      else
        # report errors if any
        response[:errors] = @upload.errors
      end
    end
  end
end

```

## In your views

```slim
  #upload-area data-button='#upload-button' data-multiple='false' data-dropzones='#upload-area'
    a#upload-button Choose a photo
```

## In your js

```coffeescript
  $('#upload-area').uploader
    request:
      endpoint: '/user_uploads'
    validation:
      allowedExtensions: ['png', 'jpg', 'jpeg', 'gif']
    callbacks:
      onComplete: (id, fileName, response) ->
        console.log('onComplete')
      onProgress: (id, fileName, loaded, total) ->
        console.log('onProgress')
      onUpload: (id, fileName) ->
        console.log('onUpload')
      onError: (id, fileName, message) ->
        console.log('onError')

This project rocks and uses MIT-LICENSE.<commit_msg>Fix typo<commit_after># Uploads - Easy uploads for rails.

1. No predefined CSS and templates.
2. Support rails CSRF TOKEN.
3. No middleware, just your controllers.
4. Use as much as possible jQuery buildin functions.

## Installation

Add it to our Gemfile

```ruby
gem 'uploads'
```

## In your controller

```ruby
class UserUploadsController < ApplicationController
  # includes Uploads module for #respond_to_upload method
  include Uploads

  def create
    # create you Upload model as usual
    @upload = current_user.user_uploads.new
    
    respond_to_upload(request) do |file, response|
      # grab uploaded file
      @upload.image = file
      # try to save it
      if response[:success] = @upload.save
        # send back upload id and image preview
        response[:user_upload_id] = @upload.id
        response[:user_upload_preview_url] = @upload.image.url(:avator_editor)
      else
        # report errors if any
        response[:errors] = @upload.errors
      end
    end
  end
end

```

## In your views

```slim
  #upload-area data-button='#upload-button' data-multiple='false' data-dropzones='#upload-area'
    a#upload-button Choose a photo
```

## In your js

```coffeescript
  $('#upload-area').uploader
    request:
      endpoint: '/user_uploads'
    validation:
      allowedExtensions: ['png', 'jpg', 'jpeg', 'gif']
    callbacks:
      onComplete: (id, fileName, response) ->
        console.log('onComplete')
      onProgress: (id, fileName, loaded, total) ->
        console.log('onProgress')
      onUpload: (id, fileName) ->
        console.log('onUpload')
      onError: (id, fileName, message) ->
        console.log('onError')

This project rocks and uses MIT-LICENSE.
{'fraction_non_alphanumeric': 0.11273364485981309, 'fraction_numerical': 0.002336448598130841, 'mean_word_length': 3.0199530516431925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7330407', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1026, 'n_words': 314}