Plugins - Asset Field
Add to favoritesAdds asset management capabilities to your model.
Usage example:
class Page
asset_field :asset,
:directory => "#{RAILS_ROOT}/public/assets/images",
:extensions => %w( .swf .qt ),
:filename => :permalink
end
This defines the following attrbitues:
- [R,W] asset_tempfile
and the following instance methods:
- Page#asset_file_on_disk Full pathname of the file on disk.
- Page#asset_exist? Does the file actually exist on disk?
- Page#write_asset_file Write the file to the path generated from the asset field’s directory option and the method referenced by the filename option.
- Page#destroy_asset_file Destroy the asset file.
Configuration options:
- :directory Directory to save this field’s assets in. Defaults to "#{RAILS_ROOT}/public/assets".
- :filename A symbol referencing the name of a method returning a string returning a filename (minus the file’s extension). It is of note that this could simply be a reference to another attribute.
- :extensions An array of allowed file extensions. Omitting this option allows all file extensions.
