Sha256: 28eaeb35ee4e4c7e05f2df53b61b3613cb6d70c41b5226a721b759dbc0b12b06

Contents?: true

Size: 549 Bytes

Versions: 12

Compression:

Stored size: 549 Bytes

Contents

# -----------------------------------------------------------------------------
# => TODO: This looks like a monkeypatch.. make this "the right way"..
ActiveRecord::Base.class_eval do
  def self.type_of name
    name = name.to_sym
    associations = self.reflect_on_all_associations.map(&:name)
    if name.match(/(.*)_id(s)?$/) and associations.include? "#{$1}#{$2}"
      :association
    elsif associations.include? name
      :association
    elsif self.attribute_names.include? name.to_s
      :attribute
    else
      :none
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bootstrap_admin-1.0.1 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-1.0.0 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.18 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.17 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.15 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.14 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.13 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.12 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.11 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.10 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.9 lib/bootstrap_admin/active_record_extensions.rb
bootstrap_admin-0.0.8 lib/bootstrap_admin/active_record_extensions.rb