# \[ANN\] Plugin: ColumnScope 1.0

**URL:** <https://www.ruby-forum.com/t/ann-plugin-columnscope-1-0/156589>\
**Category:** Rails\
**Created:** [December 30, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/ann-plugin-columnscope-1-0/156589 "2008-12-30T14:04:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian\_ASSSSmann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/48db29/32.png) [@Florian\_ASSSSmann](https://www.ruby-forum.com/u/Florian_ASSSSmann)\
**Post date:** [December 30, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/ann-plugin-columnscope-1-0/156589/1 "2008-12-30T14:04:41Z")

</div>

ColumnScope Plugin version 1.0 released!

- [http://github.com/boof/column\_scope/](http://github.com/boof/column_scope/)

ColumnScope lets you select specified values from your DB into a model  
or an array without doing :select =\> SQL\_FRAGMENT and map! {|r|r.foo}  
all the time.  
This plugin extends ActiveRecord::Base and mixes in named scopes.  
ColumnScope is a subclass of ActiveRecord::NamedScope::Scope so it can  
be chained with named scopes.

Assume we have a Page(id:integer, path:string, title:string,  
body:text, timestamps) model and we have a page listing, there is no  
need to load the whole body for every page.  
Maybe we need only the path and title:

Page.selects(:path, :title).values.all(:order =\> ‘id’) # =\> [[‘/  
foo’, ‘Foo’], [‘/bar’, ‘Bar’], …]

Further we can chain it with named scopes:

Page.published.selects(:path, :title).values.all(:order =\> ‘id’) #  
=\> [[‘/foo’, ‘Foo’], [‘/baz’, ‘Baz’], …]

# or using a shortcut

Page.published.select\_all(:path\_\_title, :order =\> ‘id’) # =\> [[‘/  
foo’, ‘Foo’], [‘/baz’, ‘Baz’], …]

When this page is shown maybe we don’t need the path and id anymore,  
but the instance of the model:

Page.published.rejects(:id, :path).find params[:id] # =\> \<Page  
title=“Foo” …\>

–  
Cheers  
Florian Aßmann
