Rails 4 ActiveRecord has a feature called references(). This allows us a better API for creating and interfacing with joins in ActiveRecord. It should be noted this the new default we won’t see deprecation warnings anymore if references are not used def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers # Rails 3.2 posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "authors.name = ?", ‘David’ ]).to_a   # Rails 4+ posts = Post.includes(:author, :comments).limit(2).references(:author).where("authors.name = ?", ‘David’) assert_equal 2, posts.size   end This is a more concise way to write the request. Another great part is the migration name parsing for the relation. $ rails generate migration AddCourseRefToUsers course:references   # this command returns class AddCourseRefToUsers < ActiveRecord::Migration def change add_reference[…]

We have already looked the the difference of extend and include in Modules. Extend includes the class level Module methods and Include includes the instance level Module methods, so today we will see how to include and extend them both. module LakeCharacteristics   # Ruby hook method def self.included(cls) cls.extend LakeData end   module LakeData def default_ph puts "8.1" new end end   def inspected # implement a counter puts "PH ph inspected" end end   class Fish include LakeCharacteristics end   f = Fish.default_ph puts f.inspected   # Without the Ruby hook method # this would need to have been written like so   class Fish include LakeCharacterisitics extend LakeCharacteristics::LakeData end :)