README.md in deep_pluck-0.1.2 vs README.md in deep_pluck-0.1.3

- old
+ new

@@ -4,13 +4,15 @@ [![Build Status](https://travis-ci.org/khiav223577/deep_pluck.svg?branch=master)](https://travis-ci.org/khiav223577/deep_pluck) [![RubyGems](http://img.shields.io/gem/dt/deep_pluck.svg?style=flat)](http://rubygems.org/gems/deep_pluck) [![Code Climate](https://codeclimate.com/github/khiav223577/deep_pluck/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/deep_pluck) [![Test Coverage](https://codeclimate.com/github/khiav223577/deep_pluck/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/deep_pluck/coverage) -Use deep_pluck as a shortcut to select one or more attributes and include associated models without loading a bunch of records. And DRY up your code when using #as_json. +Allow you to pluck deeply into nested associations without loading a bunch of records. +And DRY up your code when using #as_json. + ## Installation Add this line to your application's Gemfile: ```ruby @@ -34,15 +36,15 @@ # => [{'id' => 1, 'name' => 'David'}, {'id' => 2, 'name' => 'Jeremy'}] ``` ### Pluck deep into associations ```rb -User.deep_pluck(:name, 'posts' => :title) +User.deep_pluck(:name, :posts => :title) # SELECT `users`.`id`, `users`.`name` FROM `users` # SELECT `posts`.`user_id`, `posts`.`title` FROM `posts` WHERE `posts`.`user_id` IN (1, 2) # => [ -# {'name' => 'David' , 'posts' => [{'title' => 'post1'}, {'title' => 'post2'}]}, -# {'name' => 'Jeremy', 'posts' => [{'title' => 'post3'}]} +# {'name' => 'David' , :posts => [{'title' => 'post1'}, {'title' => 'post2'}]}, +# {'name' => 'Jeremy', :posts => [{'title' => 'post3'}]} # ] ``` ### DRY up Rails/ActiveRecord includes when using as_json