Sha256: 85e1e24177ab7a1dfc4ecae7d9021f2b58c20ee652e688c271bdad256898cc00

Contents?: true

Size: 468 Bytes

Versions: 11

Compression:

Stored size: 468 Bytes

Contents

if defined?(::ActiveRecord)
  class ActiveRecord::Base
    def self.rails_admin(&block)
      RailsAdmin::Config.model(self, &block)
    end

    def rails_admin_default_object_label_method
      self.new_record? ? "new #{self.class.to_s}" : "#{self.class.to_s} ##{self.id}"
    end

    def safe_send(value)
      if self.attributes.find{ |k,v| k.to_s == value.to_s }
        self.read_attribute(value)
      else
        self.send(value)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
rails_admin-0.0.5 config/initializers/active_record_extensions.rb
rails_admin-0.0.4 config/initializers/active_record_extensions.rb
rails_admin-0.0.3 config/initializers/active_record_extensions.rb
rails_admin-0.0.2 config/initializers/active_record_extensions.rb
upstream-rails_admin-1.0.2 config/initializers/active_record_extensions.rb
rails_admin-0.0.1 config/initializers/active_record_extensions.rb
obitum-rails_admin-0.0.5 config/initializers/active_record_extensions.rb
drewda_rails_admin-0.0.1 config/initializers/active_record_extensions.rb
obitum-rails_admin-0.0.4 config/initializers/active_record_extensions.rb
obitum-rails_admin-0.0.3 config/initializers/active_record_extensions.rb
obitum-rails_admin-0.0.2 config/initializers/active_record_extensions.rb