Sha256: 94d381573305e3b2a8dd5ba86a146813c07ef6db21c3b8e2892722f60027936e

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

module MediaMagick
  module Controller
    module Helpers
      extend ActiveSupport::Concern

      # {"embedded_in_model"=>"embedded_model", 
      #   "embedded_in_id"=>"embedded_id", "model"=>"model", 
      #   "model_id"=>"id"
      # }
      def find_doc_by_params(params)
        if params[:embedded_in_model].blank?                  
          doc = params[:model].classify.constantize.find(params[:model_id])
        else
          doc = params[:embedded_in_model].classify.constantize.find(params[:embedded_in_id]).send(params[:model].pluralize.downcase).find(params[:model_id])          
        end
        doc
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
media_magick-0.2.0 lib/media_magick/controller/helpers.rb
media_magick-0.1.1 lib/media_magick/controller/helpers.rb