Module: SmartEditor

Defined in:
lib/smart_editor.rb,
lib/smart_editor/engine.rb,
lib/smart_editor/version.rb,
app/models/smart_editor/editor_image.rb,
app/helpers/smart_editor/application_helper.rb,
app/helpers/smart_editor/editor_images_helper.rb,
lib/generators/smart_editor/smart_editor_generator.rb,
app/controllers/smart_editor/application_controller.rb,
app/controllers/smart_editor/editor_images_controller.rb

Defined Under Namespace

Modules: ApplicationHelper, EditorImagesHelper Classes: ApplicationController, EditorImage, EditorImagesController, Engine, SmartEditorGenerator

Constant Summary collapse

VERSION =
"0.0.4.1"

Class Method Summary collapse

Class Method Details

.bind_editor_images(controller, model_name, actions) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/smart_editor.rb', line 6

def self.bind_editor_images(controller, model_name, actions)
  controller.class_eval <<-eos
    before_filter :_bind_image, :only => [#{actions.map{|a| ":#{a}" } .join(",")}]
    def _bind_image
      if params[:#{model_name}][:editor_image_ids] == "[]" or params["#{model_name}"]["editor_image_ids"].blank?
        params[:#{model_name}].delete("editor_image_ids") 
      else
        params[:#{model_name}][:editor_image_ids] = params[:#{model_name}][:editor_image_ids].gsub('[','').sub(']','').split(",")
      end
    end
  eos
end