Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ample_assets

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ample_assets

  • 0.0.7
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

h1. Ample Assets

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

!http://helloample.com/images/work/screen-shot.png!

h3. 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 %>

h3. 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 %>

FAQs

Package last updated on 15 May 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc