百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
J

jack_up

> 编程语言
开源

[已弃用] Rails 中的简单 AJAX 文件上传

197 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

[已弃用] Rails 中的简单 AJAX 文件上传

Deprecated as of October 7, 2016

Given other both paid and free uploading tools available, JackUp has been deprecated.

JackUp

Easy AJAX file uploading in Rails.

Install

Modify your Gemfile:

ruby
gem 'jack_up'

and run bundle install from your shell.

Modify your application.js manifest:

javascript
//= require jquery
//= require underscore
//= require jack_up
//= require_tree .

Requirements

Rails 4.0+, CoffeeScript, and both jQuery and Underscore.js included in your application.js manifest.

Usage

Create a JackUp.Processor, binding to various events emitted.

…

Once the processor is set up, wire up drag-and-drop support:

coffeescript
  $('.file-drop').jackUpDragAndDrop(jackUp)

  # if you do not want the browser to redirect to the file when droped anywhere else on the page
  $(document).bind 'drop dragover', (e) ->
    e.preventDefault()

If you just want to bind to a standard ``:

coffeescript
  $('.standard-attachment').jackUpAjax(jackUp)

You can use both at the same time, referencing the same JackUp.Processor, in order to provide both options to your users.

Example Rails Setup

For instant file uploading:

ruby
# Gemfile
gem 'rails'
gem 'paperclip'
gem 'rack-raw-upload'

Using the rack-raw-upload gem allows for accessing the file posted to the controller via params[:file]; this makes it incredibly easy to handle file uploads.

ruby
# app/models/asset.rb
class Asset  'Drop files here' } Drop files here

%input.standard-attachment{ name: 'standard_attachment', accept: 'image/*', type: :file, multiple: :multiple }

Anything with a data-placeholder attribute will be hidden when an file is successfully dropped.

If attaching assets to a different model, additionally use:

ruby
# app/models/post.rb
class Post  'Drop files here' } Drop files here

  %input.standard-attachment{ name: 'standard_attachment', accept: "image/*", type: :file, multiple: :multiple }

  = form.submit 'Create Post'
…

License

JackUp is copyright 2012-2013 Josh Steiner, Josh Clayton, and thoughtbot, inc., and may be redistributed under the terms specified in the LICENSE file.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言