Sha256: 1090707ae03735733b404c3d1c1a00fdafaf9994b72298a9bcd5cd45494140d0

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

class ActiveRecord::Base
  def self.reflected_association(attribute)
    reflections.map { |k, v| v }.select { |e| e.foreign_key == attribute.to_s }.first
  end

  def self.accessible_attribute_names
    accessible_attributes.to_a.select { |a| a.present? }
  end

  def self.validates_presence?(attribute)
    validator = validators.select { |v| v.is_a?(ActiveModel::Validations::PresenceValidator) }.first
    validator && (validator.attributes.include?(attribute.to_sym) || validator.attributes.include?(attribute.to_s))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scaffold_markup-0.0.1 lib/scaffold_markup/extensions/active_record_extension.rb