ActiveRecord::Extensions 0.6.0 released
on May 06, 2007 @ 04:34 AM

ActiveRecord::Extensions 0.6.0 is released! You can install it via RubyGems:


gem install ar-extensions

What’s New?

0.6.0 includes:
  • support for arrays when using the Hash arguments and the ‘_contains’ suffix.
  • a synchronize method which acts like ActiveRecord::Base#reload, but it works on multiple instances. The benefit being that it makes one query to reload all instances rather then one query per instance
  • a bug fix for URI encoded strings when using find with ActiveRecord objects

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# synchronize example
post = BlogPost.find_by_author_name( 'zdennis' )
columns = [ :author_name, :title ]
values = [ [ 'yoda', 'test post' ] ]
BlogPost.import columns, values, :synchronize=>[ post ]
post.author_name # => 'yoda'

# using synchronize option with import
posts = BlogPost.find(:all)
BlogPost.import( columns, values, :synchronize=>posts)

# using arrays with the _contains suffix
BlogPost.find( 
  :all,  
  :conditions=>{ :author_name_contains=>[ 'ab', 'oc', 'ed' ] } )

Questions, Comments

zach dot dennis at gmail dot com