0.0
No release in over 3 years
Low commit activity in last 3 years
Drag and Drop Asset Management
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Ample Assets

AmpleAssets is a mountable engine that provides drag & drop file-management for Rails 3.2 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

If your model’s attribute is named something different, you can still create the association by passing a symbol to the has_asset plugin, like so…

class YourModel < ActiveRecord::Base
  ...
  has_asset :some_attr
  ...
end

Now you can invoke a drop target for your unique attribute like this…

<%= form_for @object do |f| %>
  <%= asset_drop(:your_model, :some_attr_id, :object => f.object.some_attr) %>
<% end %>