Sha256: 34e460b672e03f8c1a6f4b5ce3015682502918a16a32a94e5c4fb055c9289a49

Contents?: true

Size: 1.09 KB

Versions: 33

Compression:

Stored size: 1.09 KB

Contents

module Cms
  module Extensions
    module ActiveRecord

      module Base
        def updated_on_string(fmt="%b %e, %Y")
          if respond_to?(:updated_at) && updated_at
            updated_at.strftime(fmt).gsub(/\s{2,}/," ")
          else
            nil
          end
        end
      end

      module ClassMethods
        # Determines if the database for this Rails App exists yet. Useful for methods which might be called during
        # rake tasks or initialize where a database not yet being created is not fatal, but should be ignored.
        #
        # @return [Boolean] false if it does not exist.
        def database_exists?
          begin
            connection
            return true
          rescue StandardError # Hopefully this works with MySql, MySql2 and SQLite
            logger.warn "Attempted to establish a connection with the database, but could not do so."
            return false
          end

        end
      end
    end
  end
end
ActiveRecord::Base.send(:include, Cms::Extensions::ActiveRecord::Base)
ActiveRecord::Base.extend(Cms::Extensions::ActiveRecord::ClassMethods)


Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
browsercms-artirix-4.0.4 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.3.3 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.3.2 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.3.1 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.3 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.2 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.1.1 lib/cms/extensions/active_record/base.rb
browsercms-artirix-4.0.0.rc1.art4 lib/cms/extensions/active_record/base.rb
browsercms-4.0.0.rc1 lib/cms/extensions/active_record/base.rb
browsercms-4.0.0.beta lib/cms/extensions/active_record/base.rb
browsercms-4.0.0.alpha lib/cms/extensions/active_record/base.rb
browsercms-3.5.7 lib/cms/extensions/active_record/base.rb
browsercms-3.5.6 lib/cms/extensions/active_record/base.rb
browsercms-3.5.5 lib/cms/extensions/active_record/base.rb
browsercms-3.5.4 lib/cms/extensions/active_record/base.rb
browsercms-3.5.3 lib/cms/extensions/active_record/base.rb
browsercms-3.5.2 lib/cms/extensions/active_record/base.rb
browsercms-3.5.1 lib/cms/extensions/active_record/base.rb
browsercms-3.5.0 lib/cms/extensions/active_record/base.rb
browsercms-3.5.0.rc3 lib/cms/extensions/active_record/base.rb