Socket
Book a DemoInstallSign in
Socket

mongoid-activerecord-eagerloadable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoid-activerecord-eagerloadable

bundlerRubygems
Version
0.0.1
Version published
Maintainers
1
Created
Source

Mongoid::Activerecord::Eagerloadable

Belongs to relationships between Mongoid and ActiveRecord models. With eager loading.

Installation

Add this line to your application's Gemfile:

gem 'mongoid-activerecord-eagerloadable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongoid-activerecord-eagerloadable

Usage

Consider the following Mongoid document:

class Pet
  include Mongoid::Document
  include Mongoid::ActiveRecord::EagerLoadable

  belongs_to_active_record :person
end

And the following ActiveRecord class:

class Person < ActiveRecord::Base
  attr_accessible :name
end

The belongs_to_active_record :person statement enables the following to execute a single query against your mongodb instance and a single query against your ActiveRecord connection:

Pet.scoped.includes_active_record(:person).all.map(&:person)

Also, the person method is added to each instance of Pet regardless of whether or not the includes_active_record method is invoked

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 23 May 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts