Module Cms::Behaviors::Attaching::MacroMethods
In: lib/cms/behaviors/attaching.rb

Methods

Included Modules

InstanceMethods

Public Instance methods

[Source]

    # File lib/cms/behaviors/attaching.rb, line 13
13:         def belongs_to_attachment(options={})
14:           @belongs_to_attachment = true
15:           include InstanceMethods
16:           before_validation :process_attachment  
17:           before_save :update_attachment_if_changed
18:           after_save :clear_attachment_ivars
19:           belongs_to :attachment, :dependent => :destroy 
20:           
21:           validates_each :attachment_file do |record, attr, value|
22:             if record.attachment && !record.attachment.valid?
23:               record.attachment.errors.each do |err_field, err_value|
24:                 if err_field.to_sym == :file_path
25:                   record.errors.add(:attachment_file_path, err_value)
26:                 else  
27:                   record.errors.add(:attachment_file, err_value)
28:                 end
29:               end      
30:             end
31:           end       
32:         end

[Source]

    # File lib/cms/behaviors/attaching.rb, line 10
10:         def belongs_to_attachment?
11:           !!@belongs_to_attachment
12:         end

[Validate]