Skip to content

tcmacdonald/ample_assets

 
 

Repository files navigation

Ample Assets

AmpleAssets is a mountable engine that provides drag & drop file-management for Rails 3.1 applications.

Example Usage

Add the following to your Gemfile and bundle…

gem 'ample_assets', :git => 'https://github.com/ample/ample_assets.git'

Run the generator to copy over the necessary migrations…

rails g ample_assets:install

You’ll need to create a foreign_key on the model with which you plan to integrate AmpleAssets. For the purposes of this example, let’s assume your model is named Post

rails g migration add_file_id_to_posts file_id:integer

Now you’re ready to migrate…

rake db:migrate

Add the following plugin to your model…

class Post < ActiveRecord::Base
  ...
  has_asset
  ...
end

In both of your manifest files (stylesheets & javascripts) require ample_assets, for example…

/**
 *= require ample_assets
 */

Add the engine to your app’s routes.rb file…

mount AmpleAssets::Engine => "/ample_assets", :as => "ample_assets"

To invoke the asset toolbar, include the following in any view…

<%= assets_toolbar %>

To invoke a new drop_target, include the following within a form attached to your model…

<%= form_for current_page do |f| %>
  <%= f.asset_drop(:file_id) %>
<% end %>

Configuration

AmpleAssets.configure do |config|
  config.mount_at = YOUR PATH PREFIX
end

About

Drag and drop file management for Rails.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 45.3%
  • Ruby 32.0%
  • CoffeeScript 22.7%