Module: Fleximage::AviaryController::ClassMethods

Defined in:
lib/fleximage/aviary_controller.rb

Instance Method Summary collapse

Instance Method Details

#editable_in_aviary(model_class, options = {}) ⇒ Object

Invoke this method to enable this controller to allow editing of images via Aviary



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fleximage/aviary_controller.rb', line 20

def editable_in_aviary(model_class, options = {})
  unless options.has_key?(:secret)
    raise ArgumentError, ":secret key in options is required.\nExample: editable_in_aviary(Photo, :secret => \"My-deep-dark-secret\")"
  end
  
  # Don't verify authenticity for aviary callback
  protect_from_forgery :except => :aviary_image_update 
  
  # Include the necesary instance methods
  include Fleximage::AviaryController::InstanceMethods
  
  # Add before_filter to secure aviary actions
  before_filter :aviary_image_security, :only => [:aviary_image, :aviary_image_update]
  
  # Allow the view access to the image hash generation method
  helper_method :aviary_image_hash
  
  # Save the Fleximage model class
  model_class = model_class.constantize if model_class.is_a?(String)
  dsl_accessor :aviary_model_class, :default => model_class
  dsl_accessor :aviary_secret, :default => options[:secret]
end