FileManagerEngine
Rails 3 engine to track used files elsewhere in your models.
Have you ever deleted a file without knowing if it was being used? Are they broken links to images? Were they removed regardless of where they were used?
With FileManagerEngine you can keep track of all the files used in your application and you will see where they are being used before deleting them and not make mistakes corrupt leaving your links or wrong your posts.
Getting Started
Install
Add this line to your Gemfile:
gem file_manager_engine
And execute bundle install
Models
You need add this lines to used FileManager in your app:
include 'FileManagerEngine"
self.file_field_name = [name field]
name_field is refered to name the field or scope how you used to relationated the entity with the file or files included in the instance to save.
Examples:
If a new post used a file image called "foto.jpg" and Post entity has a field called "image_id" to refered with this image file, then you self.file_field_name = :image_id
Other case, if you don't have a entity to admin files, and you insert a files by their path and the post entity has a field called "path" you self.file_field_name = :path.
In conclusion, this params is used to search the file when you need to delete it and search the relation with the rest of entities in your model.
Using in View
When you go to remove some file in your app interface (for example, administrator), you should use this command in the remove's process:
FileManager.used_in([file])
Where file is the value which It's returned by self.file_field_name
in the entities which used
FileManager gem.
LICENSE
[MIT License]. Copyright 2012 G. Gutiérrez & J. Vázquez.