Module: DirectWave::ActiveRecord
- Includes:
- Mounter
- Defined in:
- lib/directwave/orm/activerecord.rb
Instance Method Summary collapse
-
#mount_directwave(column, uploader = nil) ⇒ Object
See DirectWave::Mounter#mount_uploader for documentation.
Methods included from Mounter
Instance Method Details
#mount_directwave(column, uploader = nil) ⇒ Object
See DirectWave::Mounter#mount_uploader for documentation
Added instance methods
Supposing a class has used mount_uploader
to mount an uploader on a column named image
, in that case the following methods will be added to the class:
- #column_from_key
-
Returns the key of assigned file
- #column_from_key=
-
Assign file from S3 key
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/directwave/orm/activerecord.rb', line 20 def mount_directwave(column, uploader=nil) super instance_eval <<-RUBY, __FILE__, __LINE__+1 RUBY class_eval <<-RUBY, __FILE__, __LINE__+1 attr_accessible :#{column}_from_key def #{column}_from_key send(:#{column}).store_key end def #{column}_from_key=(string) send(:#{column}).store_key = string end before_save do send(:#{column}).save end after_destroy do send(:#{column}).destroy end RUBY end |