Sha256: c331ccfd06d02a0e111773fe0ca61c468fea568337f6bfc4ca5881bff6a2e896
Contents?: true
Size: 1.9 KB
Versions: 17
Compression:
Stored size: 1.9 KB
Contents
require 'tinymce-rails' require 'jquery-ui-rails' require 'colorbox-rails' require 'paperclip' class ActiveRecord::Base # (PLU)cks a single uni(Q)ue field def self.pluq(field, compact = true, sort = true) arr = self.uniq.pluck(field) return [] if arr.nil? arr = arr.compact if compact arr = arr.sort if sort return arr end end module Caboose def Caboose.log(message, title = nil) if (Rails.logger.nil?) puts "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" puts title.to_s unless title.nil? puts message puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" else Rails.logger.debug("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") Rails.logger.debug(title.to_s) unless title.nil? Rails.logger.debug(message) Rails.logger.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n") end end def Caboose.plugin_hook(*args) resp = nil args[0] = args[0].to_sym Caboose.plugins.each do |mod| #resp = mod.constantize.send(*args) if (mod.constantize.respond_to?(args[0])) resp = mod.constantize.send(*args) end end return resp end def Caboose.json(obj, defaultvalue = "") return defaultvalue.to_json if obj.nil? return obj.to_json end # Strips html and returns the text that breaks closest to the given length def Caboose.teaser_text(str, length = 100) return "" if str.nil? str2 = ActionController::Base.helpers.strip_tags(str) if str2.length > 200 i = str2.index(' ', 200) - 1 i = 200 if i.nil? str2 = str2[0..i] str2[str2.length-1] = "" if str2.ends_with?(",") str2 = "#{str2}..." end return str2 end class Engine < ::Rails::Engine isolate_namespace Caboose end end
Version data entries
17 entries across 17 versions & 1 rubygems