0
I Use This!
Activity Not Available

Project Summary

OverviewActiveUpload is Rails plugin that allows you to quickly and easily accept uploaded files and attach them to any model in your application. It uses a slightly modified version SWFUpload to create an elegant user experience, while at the same time being simple and flexible for the developer.

ActiveUpload also works with ActiveScaffold. See the ActiveScaffold section below for details.

InstallationTo install and and use the plugin, perform the following steps.

First install the plugin:

./script/plugin install http://activeupload.googlecode.com/svn/trunk/activeupload/Second, generate the migration, model and controller

./script/generate activeuploadThird, add the following lines to any model you wish to attach files to:

has_many :attachments, :as => :attachable

def attachment_id=(attachment_id)
unless attachment_id.blank?
attachments.clear
attachment_ids = attachment_id.split(",")
attachment_ids.each do |a_id|
unless a_id.blank?
attachment = Attachment.find(a_id)
attachments << attachment
end
end
end
end

def attachment_id
result = ""
if attachments
attachments.each do |attachment|
result << ",#{attachment.id}"
end
end
result
endFourth, add the form helpers to your new and edit views:


Attachments
<%= f.attachments_field :attachment_id, { :add => "true", :edit =>"true", :filesize => 30720, :filetypes => [ "*.gif", "*.jpg", "*.png" ] } %>

Fifth, add the view helper to your show view:


Attachments

Sixth and lastly, add the javascript and stylesheets to your layout:

<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag 'swfupload_theme' %>
<%= javascript_include_tag "swfupload_callbacks.js" %>
<%= javascript_include_tag "SWFUpload.js" %>ActiveScaffoldActiveUpload works well with ActiveScaffold. To get ActiveScaffold to render the correct upload forms you must create a partial form override. Luckily, ActiveUpload comes with one. In the plugin's public directory ($PROJECT/vendor/plugins/activeupload/public/) you will find a file named attachment_id_form_column.rhtml. Copy that file to your models views directory ($PROJECT/app/views/$MODEL/).

cp vendor/plugins/activeupload/public/_attachment_id_form_column.rhtml app/views/modelSince attachment_id is a virtual column, you will need to tell ActiveScaffold to use it, you can do that by adding the following code to your model's controller:

active_scaffold :model_name do |config|
config.create.columns = [:column1, :column2, :attachment_id]
config.update.columns = [:column1, :column2, :attachment_id]
endFinally, add the following code to your attachments_controller:

active_scaffold

Tags

assaydepot files fileuploads plugin rails ruby rubyonrails swfupload upload

In a Nutshell, activeupload...

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

MIT License
Permitted

Sub-License

Private Use

Commercial Use

Modify

Distribute

Forbidden

Hold Liable

Required

Include Copyright

Include License

These details are provided for information only. No information here is legal advice and should not be used as such.

All Licenses

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    Black Duck offers a free trial so you can discover if there are open source vulnerabilities in your code
  • ...
    by exploring contributors within projects, you can view details on every commit they have made to that project
  • ...
    use of OSS increased in 65% of companies in 2016
  • ...
    data presented on the Open Hub is available through our API

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

Community Rating

Be the first to rate this project
Click to add your rating
   Spinner
Review this Project!
Sample ohloh analysis