Tuesday, August 4, 2009

Usefulness of named scope in remote console

Fancy searching through records in production database in a SSH terminal? You can always query them via good o' SQL but I find that rather cumbersome.

select * from payment_transactions outer left join utility_providers ..... where .....

Too long... what about activerecord objects using script/console?

PaymentTransaction.find(:all, :conditions => [........])

Better but the conditions string can get unweldy. But why not use namedscopes?


Short and sweet! Plus if you use the Searchlogic gem, these namedscopes comes for free! :)

No comments:

Blog Archive