attachment_fu plugin

attachment_fu plugin seems the choice of file uploading. it is the rewritten version of acts_as_attachment

Just follow these instructions and you should be good to go: http://clarkware.com/cgi/blosxom/2007/02/24

In most cases, you will probably want to add multiple image/files to a post/page/applicationform/etc so I would recommend following the clarkware tutorial above, and then doing a has_many and belongs_to with the necessary form structure to add images/files to your form and its model.

Deleting files To delete files using attachment_fu plugin you can do the following if they are associated with something else. code

PRODUCTION Also, there is a good chance that attachment_fu will not work in production mode, and kick out some difficult to discover error. Here?s the solution

Also, the folder will get removed on deployment. Here?s a tutorial to help solve that problem

Here is what the end of my deploy.rb file looks like. My attachment_fu images are stored in public/attachments/

desc 'Fix attachment_fu'
task :fix_attachment_fu, :roles => :app do
  %w{attachments}.each do |share|
    run "rm -rf #{release_path}/public/#{share}"
    run "mkdir -p #{shared_path}/system/#{share}"
    run "ln -nfs #{shared_path}/system/#{share} #{release_path}/public/#{share}"
  end
end

desc "Reload Nginx"
task :reload_nginx do
  sudo "/etc/init.d/nginx reload"
end

desc "Restart Thin"
task :restart_thin do
  sudo "/etc/init.d/thin restart"
end

after "deploy", "deploy:cleanup"
after "deploy:cleanup", "fix_attachment_fu"
after "fix_attachment_fu", "reload_nginx"
after "reload_nginx", "restart_thin"

Comments