#108
May 19, 2008

named_scope

The named_scope method in Rails 2.1 makes performing finds on models very elegant and convenient. See how in this episode.
Download (12.5 MB, 11:02)
alternative download for iPod & Apple TV (12.1 MB, 11:02)

Note: there’s a lot more to the named_scope method which I didn’t cover, please see the links below for additional info.

# models/product.rb
class Product < ActiveRecord::Base
  belongs_to :category
  named_scope :cheap, :conditions => { :price => 0..5 }
  named_scope :recent, lambda { |*args| {:conditions => ["released_at > ?", (args.first || 2.weeks.ago)]} }
  named_scope :visible, :include => :category, :conditions => { 'categories.hidden' => false }
end

RSS Feed for Episode Comments 285 comments

1. Adam Hill May 19, 2008 at 02:55

Wow, and I thought working with the DB couldn't get any easier, but this is seriously cool. Thanks for this excellent overview.

I wonder if these named scopes can be used in conjunction within existing search plugins like acts_as_ferret in one line...


2. Foo May 19, 2008 at 04:11

Another great screencast.

Does this essentially make all self.finds obsolete? Will the new conventions be named_scope instead of def self.find_some_criteria?


3. grigio May 19, 2008 at 04:21

Thanks for these Rails 2.1 tips.


4. hoksitan May 19, 2008 at 04:50

Very interesting screencast ! Cool new feature ! Thanks for this tip !


5. Mauricio May 19, 2008 at 06:12

What about the performance cost of this "magic"?


6. Marcel May 19, 2008 at 06:19

Wow, this looks really cool. I especially like the efficiency of the generated SQL query when you concatenated the named_scopes. Really amazing and definately a great feature for bigger, data-filled applications.

Thanks for another great screencast!


7. Clemens Kofler May 19, 2008 at 06:41

Foo:
I would guess that yes, pretty much all finds will be replaced by named scopes in near future. Think of your own experience and some of Ryan's previous screencasts: You shouldn't really have finds anyway as soon as you're using find conditions. Like, say, you'd have find_all_activated instead of find(:all, :conditions => "activated_at IS NOT NULL")

Mauricio:
As far as I can see in the source, there's not too much going on metaprogramming-wise. So I guess it's safe to say that scoping doesn't cause performance issues. And as Marcel points out, named scopes produce really clean and efficient SQL - so no problem there either. Plus, scopes have existed before in Rails (with_scope - see here: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001416).

Ryan:
Best episode so far, in my opinion. And not only because it was so long! ;-)


8. Ryan Bates May 19, 2008 at 08:01

@Adam, I doubt you can use this with acts_as_ferret, but other plugins which end up calling "find" should work. For example, will_paginate just adds a custom paginate class method. You can append this to the search. (Untested).

Product.recent.paginate(:page => 1)

@Foo, this definitely lowers the need to create custom "self.find..." methods. However I would hesitate getting too fancy here. If you have a complicated search which needs to dynamically build up the conditions based on the passed parameters, then I wouldn't use named_scope for this.

@Mauricio, to echo Clemens, I doubt performance will be much of an issue. There's probably a slight overhead on the ruby side to get the scoping stuff figured out, but beyond that it seems efficient.


9. Radarek May 19, 2008 at 12:15

@Ryan:
  in Ruby 1.9 you can use -> operator for lambda and put default values, like this:

named_scope :recent, ->(time = 2.weeks.ago) { {:conditions => ["released_at > ?", time]} }


10. Matt Beedle May 19, 2008 at 12:54

I've been using has_finder for a while now, and it's been a real pleasure to work with. I'm really glad it's made it into rails.


11. Jeremy May 19, 2008 at 14:07

I have been using edge rails as of late just for this amazing functionality. In addition to the new level of dynamism this feature adds to Rails, it also adds such simplicity.

My favorite has to be simply the Model.all, Model.first, and Model.last shortcuts... cleans up my controllers for sure!

Man, with each new update of Rails, so many new possibilities for refactoring!


12. Carl May 19, 2008 at 15:18

I have been trying to do some of the same things using with_scope and some of them were not working correctly (I have an idea why now after watching your screencast) and now it will be so much easier to do what I was trying to do. Thanks for telling me about this new feature!


13. Soleone May 19, 2008 at 22:58

Indeed a very cool screencast.

Thanks again for this great episode!


14. Mathijs May 19, 2008 at 23:34

I've been using the has_finder gem on which this is based for some time now, and it's really useful. One thing I still struggle with has to do with using named_scopes between models in associations.

In your example you are using 'visible' which is just a simple attribute. What if category had more advanced attributes, like hidden, private, public, read_only and stuff like that. Say Category already has some named_scopes, for example 'free_for_all' which means a category is public but not read-only.

Now it would make sense (maybe not in this example but in general) to be able to use these named_scopes in the Product model, not on instances only, but in named_scopes themselves as well. So Product.in_free_for_all can just use the 'free_for_all' scope in Category. Otherwise you would have to define this 'logic' twice, which isn't very DRY. I hope my explanation is clear enough :)

Of course I know that I could also use Category.free_for_all.map(&:products), but then all products get fetched right away which means sorting them (and other nice stuff finders have) will have to be done in ruby instead of in the DB.

Any 'nice' solutions for this?


15. Mathijs May 19, 2008 at 23:46

A solution I use at the moment is this, but I'm not fully satisfied with it yet, so any comments are very welcome...

class Product << ActiveRecord::Base
  belongs_to :category
  named_scope :in_free_for_all, lambda {{ :conditions => {:category_id => Category.free_for_all.map(&:id)} }}
end

Which will do 2 queries, which is default for :include in rails 2.1 anyway I believe. I could use :select => 'id' to speed up the query a bit since I only need id's, but in the end, it would be nicest if rails could somehow write a subquery for it. Along the lines of:

(example, doesn't work)

named_scope :in_free_for_all, :conditions => {:category => Category.free_for_all}

should translate to:
Select * from products where category_id in (select id from categories where public = 't' and read_only = 'f')

Any chance of getting behavior like this in the near future?


16. Ryan Bates May 20, 2008 at 07:55

@Mathijs, currently one named scope can't use another named scope, but I think many people are wanting this feature. There's already a couple tickets along this line:

http://rails.lighthouseapp.com/projects/8994/tickets/57
http://rails.lighthouseapp.com/projects/8994/tickets/223

However, neither of these mention using an association's scope. You may want to add a comment to those tickets about that.


17. Brad May 20, 2008 at 09:25

Thanks for a great post! My attention tends to drift after about 7 minutes, so i'll have to come back and watch again a couple times :)


18. ESPNDev May 20, 2008 at 16:26

This was a really great Railscast highlighting probably my favorite new feature of Rails. Those SQL queries are great! Can't wait to take advantage of this...

Thanks!


19. Bryan May 21, 2008 at 04:08

Wow! Truly awesome new feature!
Now I just need to get Hostgator to update to 2.1....


20. Bharat May 26, 2008 at 14:37

Hello Ryan (or anyone else who knows),
Great screencast. In your demo, you are typing the commands in the console and showing the SQL queries in the console below. How do you isolate the SQL Queries display in the window below? It is quite useful. A screencast summarizing the tips on using Rails Console for these kinds of tricks would be very useful.
Keep up the good work.
Regards,
Bharat


21. Olafski Jun 04, 2008 at 06:16

@Bharat: you could just keep a window with ``tail -f log/development.log'' open, that should show the queries. I prefer to have them in the same window though, and have explained how to achieve this here:
http://skionrails.wordpress.com/2008/05/22/loading-additional-files-when-starting-scriptconsole/

Hope that helps. Great work as always Ryan :)


22. Walter Horstman Jun 13, 2008 at 03:34

On my website there is a page to view standings for a so called soccer pool. There are member records with a name per pool, that can be left empty. Each member is linked to a user record with a name field as well. In case the name of the member is empty, the user's name is used in the standings.

When using named_scope, I see strange behavior, since the eager loading isn't quite as I expected. I guess things have been changed in Rails 2.1 in this area that have not necessarily have to do with named_scope.

Anyway, in my Member class this scope doesn't work:

named_scope :standings, :include => :user, :order => 'members.position, COALESCE(members.name, users.name)'

The query doesn't join with the users table, so a missing column error is returned. But when I add :conditions => 'users.id = users.id', it works! So is Rails looking in the conditions to see if a associated table is used?

Anybody see my points and have some clues/comments?


23. tom Jun 13, 2008 at 10:16

Hi
im getting this:
named_scope > NoMethodError

ruby-v
ruby 1.8.5 (2006-08-25) [i486-linux]

rails-v
Rails 2.1.0

gem1.8 list
*** LOCAL GEMS ***

actionmailer (2.1.0, 2.0.2)
actionpack (2.1.0, 2.0.2)
activerecord (2.1.0, 2.0.2)
activeresource (2.1.0, 2.0.2)
activesupport (2.1.0, 2.0.2)
jruby-openssl (0.2.3)
rails (2.1.0, 2.0.2)
rake (0.8.1)

my problem / question: as soon as i have a named_scope declaration within the class, im experiencing the error above ( NoMethodError)

what am i doing wrong/missing?

thx tom


24. tom Jun 13, 2008 at 10:46

never , i figures it out, its working now on the console.as a newbie i forgot to chnage envrinment.rb

thx


25. chris Jul 01, 2008 at 21:54

hi ryan, great job as usual. quick question for you... when you are working around the inability to pass in a default value for the lamdba, you splat args and then in the proc you use "args.first || 2.weeks.ago"...

my question is why? why not just leave the argument to the lambda as "t" and then in the proc use "t || 2.weeks.ago" ?

seems to work for me, but i'm wondering if you had some other rationale for using the splat/first method.


26. Nico Jul 09, 2008 at 22:02

You can also pass in a params hash into the named scope and use for example params[:newer_than] || 2.weeks.ago for the default parameter. I prefer this solution over using args when having more than one parameter as the named scope call becomes easier to understand and parameter order doesn't matter.


27. ryanL Jul 17, 2008 at 23:45

hey Ryan, still working on that image trouble. I'll let you know when i get it sorted out.

had a tricky scope question though.

Is it possible to order a find call my an associated model's attribute.

e.g.

@category.members.order_by_members_businesses_names do |member|

i would just do

@category.businesses.order_by_name do |business|

but i the member model has addtional info i need to access.

named_scope :order_by_members_businesses_names ...?


28. Matt Aug 01, 2008 at 10:33

So would this replace the need to use the scope out plugin?


29. Philip (flip) Kromer Aug 24, 2008 at 01:38

@chris ("why not just leave the argument to the lambda as "t" and then in the proc use "t || 2.weeks.ago" ?"):

It's so you can leave the arg out -- it fakes an optional parameter.

See:
  http://pastie.org/258863


30. Pete Sep 05, 2008 at 07:53

This is so easy, it's great! Thanks for the walkthrough.


31. Edgard Sep 25, 2008 at 10:26

Hi,

You didn't try the case where 2 named_scope have a block of code. In your screencast only :recent ha a block of code, but what about chaining it with :cheap that also had a block of code?

I can't make it work.


32. Zubin Oct 12, 2008 at 03:56

If anyone's interested, I've created a plugin which automagically generates common named scopes for all AR models and columns. See http://github.com/zubin/autoscope

>> Page
=> Page(id: integer, name: string, content: text, enabled: boolean, category_id: integer, created_at: datetime, updated_at: datetime)

...creates these (for example):
>> Page.enabled
>> Page.not_enabled
>> Page.named "foo"
>> Page.content_contains "bar"
>> Page.created_before 1.year.ago

Install:
./script/plugin install git://github.com/zubin/autoscope.git

Feedback welcome!


33. Achim Oct 12, 2008 at 16:00

Thank you very much for this screencast.
Your tip about working with optional arguments saved my live :-)

Really great screencast again Ryan


34. Steffen Dec 03, 2008 at 01:42

Thanks again for this great episode!
Just what I have been looking for!


35. Jason Dec 03, 2008 at 08:56

Hi Ryan,

Thanks so much for all your work. Question - I'm seeing that
scope = Product.scoped({})
is indeed doing a find which is undesired in my case. I'm on Rails 2.1. I'd like to build up the scopes before executing. Do I need to use your scope_builder?

Thanks!


36. Jason Dec 03, 2008 at 09:16

Per comment #44 by me:

I was in the console when testing this. Appears to be ok when running in Rails.

Sorry for any confusion. Still seems a bit weird though.


37. MTH Dec 31, 2008 at 00:19

In fact, I'm using your episodes instead of Rails API!

Thanks for sharing!


38. Arjun Mar 04, 2009 at 23:50

Hi,

I have been trying to get the named scopes to work in my model without any success.
I have model called Contact.

And my named scope is like the follow:-
class Contact < ActiveRecord::Base
named_scope :guardians, {:conditions =>["relationship = ?", 'Guardian']}

And in the IRB:-
>contact = Contact.find(2)
>contact.guardians

gives the following error:
NoMethodError: undefined method `gaudians' for #<Contact:0x636d4e4>
        from F:/Projects/WorkshopProjects/testproject/vendor/rails/activerecord/lib/active_record/attribute_method
s.rb:256:in `method_missing'
        from (irb):7

I am not sure what is going wrong.

I even tried using lambda as follows, but same thing happens:-
named_scope :test_guardians, lambda { { :conditions => ['relationship = ?', 'Guardian'] } }

Can you help me out here ?

Thanks in advance.

-Arjun


39. DM500C Mar 19, 2009 at 03:02

I have been trying to get the named scopes to work in my model without any success. How to do next?


40. ruby_seattle Apr 14, 2009 at 20:57

Ryan, or any other expert,

I'm such a fan of named scopes now and see so many opportunities to streamline code. I ran into a problem. How can I create a named scope that uses an association and a lambda expression for parameterization. For example how would you retrieve all the products that are from a certain category type, for example 'electronics'. When I try something analagous to this I get an error: wrong number of arguments (3 for2).

named_scope :retrieve_by_type, :include=>:category, lambda{|type_id| {:conditions=>['categories.type'=type_id]}

-Thanks in advance


41. tomas Jun 11, 2009 at 08:05

Hi,
i'm new, how can i see generated queries like you do in the bottom terminal ?


42. Mike Jun 19, 2009 at 10:15

Since this was not clearly stated in text form I thought I would include this little snippet from the documentation on named_scope:

-----------------------
Unlike Shirt.find(...), however, the object returned by Shirt.red is not an Array; it resembles the association object constructed by a has_many declaration. For instance, you can invoke Shirt.red.find(:first), Shirt.red.count, Shirt.red.find(:all, :conditions => {:size => ‘small’}). Also, just as with the association objects, named \scopes act like an Array, implementing Enumerable; Shirt.red.each(&block), Shirt.red.first, and Shirt.red.inject(memo, &block) all behave as if Shirt.red really was an Array.


43. tuzcuoğlu nakliyat Aug 22, 2009 at 18:57

I am always been a great fan of your railscast. Keep up the good work.


44. ideal kilo Sep 05, 2009 at 13:33

Download it, very useful for me, thank you !


45. lm Sep 20, 2009 at 18:14

Could it be possible to have a named_scope that include columns from another association?

something like:
named_scope :my_fields,:select => "..."
or maybe another way?

Thanks


46. Aşk Büyüsü Oct 29, 2009 at 08:05

thans


47. cinsellik sohbet Nov 06, 2009 at 14:24

If they are linking from the comment, I would consider it spam. If they post a comment, and it is on topic, be glad someone saw your blog and thought enough to post to it. http://www.hayda.net/


48. cinsel Nov 09, 2009 at 12:40

thanks admincik


49. çuval Nov 18, 2009 at 10:24

firmamız çuval ve çuval imalatı yapmaktadır


50. direk izle Nov 23, 2009 at 16:38

I recently came across your blog and have been reading along


51. oyunlar Nov 24, 2009 at 11:11

very nice thanks...


52. Jassy Nov 26, 2009 at 14:01

clear codes ... i use your class (:


53. Dans Kursları Nov 28, 2009 at 11:25

Thanks a nice theory


54. kraloyun Dec 11, 2009 at 04:06

Thanks very good


55. mod converter Dec 16, 2009 at 18:17

lalalala ....morning.


56. buy penegra Dec 18, 2009 at 06:22

hey nice blog about named_scope


57. forum Dec 20, 2009 at 08:40

thanks you adminbey


58. WTF Dec 20, 2009 at 15:20

thanx for that.


59. lig golleri Dec 20, 2009 at 15:20

amk nofollow ama idare edicez artık. tenks edmin.


60. Sinema izle Dec 20, 2009 at 15:28

Thanks very good..


61. full oyun Dec 20, 2009 at 15:38

thankss perfect


62. muhteşem kraliçe Dec 21, 2009 at 02:50

muhteşem kraliçe dizisi trt1


63. Mustafa Can Dec 21, 2009 at 05:19

Thanks for a great post! My attention tends to drift after about 7 minutes, so i'll have to come back and watch again a couple times :)


64. tecavüz pornosu Dec 21, 2009 at 07:41

very good thanks


65. oyun indir Dec 21, 2009 at 08:49

Thanks for a great post! My attention tends to drift after about 7 minutes, so i'll have to come back and watch again a couple times :)


66. Orhan Dec 21, 2009 at 09:20

good performance, thanks


67. rimeysa Dec 21, 2009 at 09:22

thanks wery good.


68. ssk Dec 21, 2009 at 09:24

hello
good performance thanks


69. 0 km Dec 21, 2009 at 10:38

Nice post


70. Sigorta Dec 21, 2009 at 11:26

Thanks
http://www.sigortasorgulama.net


71. galatasaray Dec 21, 2009 at 12:52

thanks admins


72. su deposu Dec 23, 2009 at 02:09

thanks admin very good


73. besmele Dec 24, 2009 at 03:32

a great site. I too enjoy. I wish you success


74. Dans Kursu Dec 24, 2009 at 04:43

Very nice sharing thanks


75. karın germe Dec 25, 2009 at 13:35

karın germe ameliyatı


76. arama rehberi Jan 12, 2010 at 01:36

Hi I found your site from google. I enjoy your site too. thanks


77. Çene Ameliyatı Jan 14, 2010 at 05:15

to friends here agree. They all say the right things likewise.


78. iyimi Jan 16, 2010 at 04:43

A very good article, I will always come in.


79. sarki sözleri Jan 16, 2010 at 04:45

thank you


80. orjin Jan 17, 2010 at 22:38

to friends here agree. They all say the right things likewise.


81. sikis izle Jan 20, 2010 at 18:14

Thanks for another great screencast!


82. amatorsikis Jan 20, 2010 at 18:15

Very nice sharing thanks


83. sicaksikis Jan 20, 2010 at 18:16

I've been using has_finder for a while now, and it's been a real pleasure to work with. I'm really glad it's made it into rails


84. lice Jan 22, 2010 at 02:29

Thank you for the post, really helped me a lot :)


85. Oyunu Oyna Jan 26, 2010 at 01:30

Nice post.


86. us drugstore Jan 28, 2010 at 22:55

Thanks for the review, but I think many people are wanting this feature.


87. Muhabbet Jan 30, 2010 at 17:27

Tnaks


88. forumturka Feb 02, 2010 at 08:40

thank you.. nice


89. ACE Feb 10, 2010 at 07:35

thanks for the great info.


90. MA Landscapers Feb 17, 2010 at 18:18

Thanks for the share!


91. amator sikis Feb 21, 2010 at 17:22

thank you.. nice


92. Revizyon ile Organize Matbaacı Feb 22, 2010 at 05:02

Thanks for these Rails 2.1 tips. Thanks for these Rails 2.1 tips.


93. aycaay Feb 22, 2010 at 13:06

thanks


94. TrueVision Feb 23, 2010 at 07:27

Thanks a lot for sharing it.


95. helen mclee Feb 25, 2010 at 20:10

thanks for this nice easy solution to a prob i was having in my DB. this will save a pile of time for me... thx


96. Feel-Live-Pharmacy Mar 01, 2010 at 08:45

Thanks for the post!


97. warcraft millionaire download Mar 02, 2010 at 12:22

this is a great post!


98. cheap phones for sale Mar 02, 2010 at 12:22

cool stuff!


99. Patek Nautilus Mar 02, 2010 at 23:52

bookmarked. thank you admin


100. Yeni Diziler Mar 10, 2010 at 14:17

Thank you very much for your geat post...


101. Buy Acai Berry Mar 11, 2010 at 20:45

I will definitely try these types of rail casts . Thanks for sharing information about these.


102. Water damage Folsom Mar 12, 2010 at 10:44

Yip, I agree, another great screencast.

Quick questions, does this make all self.finds obsolete? Will the new conventions be named_scope instead of def self.find_some_criteria?


103. oyun hileleri Mar 14, 2010 at 10:56

I agree with you, good luck.thanks


104. SiktiSikiyor Mar 20, 2010 at 09:53

The new GHD.IV Styler is one of many hair care products in the most popular, which makes it easy for colleges and universities has straight hair. So you can always have a beautiful flowing straight hair, the use of imported PTC heating elements, fast heat up 180 degrees temperature does not harm hair, smooth ceramicsurface, straightened hair


105. seks hikayeleri Mar 20, 2010 at 16:32

very very good share


106. minibüs kiralama Mar 20, 2010 at 16:33

thanks for you good share


107. sikis izle Mar 21, 2010 at 18:49

The trick, if there is such a thing, is variety. Make certain you collect a steady and varied collection of links


108. Mesut Mar 27, 2010 at 09:38

Thank you good post. very nice


109. Mesut Mar 27, 2010 at 09:39

Thank you good post. very nice


110. sinema izle Mar 27, 2010 at 10:42

sinema izlemeyi severim

Thank you very rich indeed a site


111. シティゴールドカード Mar 28, 2010 at 23:01

Thank you good post. very nice


112. 格安レンタカー比較 Mar 29, 2010 at 02:47

The trick, if there is such a thing, is variety. Make certain you collect a steady and varied collection of links


113. indir Mar 31, 2010 at 16:56

thanks so much.
<a title="indir" href="http://www.fullpaylas.net/">indir</a>


114. Ebutube Apr 04, 2010 at 08:12

Thanks.. for a great share

<a href="http://www.ebutube.org" title="Ebutube" rel="nofollow">Free Porn Videos - Ücretsiz Video İzle</a>


115. pim Apr 07, 2010 at 03:34

Nobel Peace Prize winner, President Obama, the country will be implemented in the next 10 years, announces new nuclear weapons strategy. Accordingly, the U.S., even in the event of biological or chemical attack will not apply to the atomic bomb. However, exceptions of Iran and North Korea.


116. internetten para kazanma yolları Apr 07, 2010 at 11:28

Thanks a lot for the valuable information provided. We will look forward in more content like this.

http://www.hitbedava.com
http://www.agrisevdasi.com
http://www.onlynpara.tr.gg
http://www.paradelisi.tr.gg


117. kızlık bozma Apr 08, 2010 at 09:13

thanks


118. Alev Apr 08, 2010 at 13:30

thanks


119. yenimoda Apr 13, 2010 at 15:11

Thank you very rich indeed a site http://yenimoda.blogspot.com/


120. online film izle Apr 14, 2010 at 05:09

More expect thanks for sharing good luck


121. film seyret Apr 14, 2010 at 05:44

thanks you


122. discountbatteryus Apr 16, 2010 at 20:00

Thank you for your sharing.


123. KV-RENT Apr 17, 2010 at 03:47

goooodddd


124. Buy Acai Berry Diets Apr 19, 2010 at 09:07

this is lovely!


125. accessoires Wii Apr 19, 2010 at 13:57

thanks for your sharing.


126. teresa Apr 19, 2010 at 20:14

thanks for your sharing.


127. pornoizliyor Apr 23, 2010 at 04:53

want to consider one of these "private boarding schools


128. Buy Acai Berry Diets Apr 24, 2010 at 07:55

this is a really cool theme!


129. 从化生活网 Apr 27, 2010 at 00:58

this is a really cool theme!


130. buy Propecia 5mg pills Apr 27, 2010 at 08:12

nice suggestion


131. flim izle Apr 29, 2010 at 16:10

thank you admin good post!


132. Play Free Slots May 03, 2010 at 22:20

Your post is quite informative and to the point. I have bookmarked to check out new stuff you post.


133. kızlık bozma May 04, 2010 at 17:38

omg bu dopeeeeeeee olduğunu


134. LCD Monitor May 04, 2010 at 23:29

very very good post. <a href="http://www.super-e-world.com/LCD-Monitor/7-inch.php">7 inch LCD Monitor</a>


135. indirmeden film izle May 08, 2010 at 19:03

Thanks a lot


136. Pes 2011 May 08, 2010 at 22:08

thankss


137. sikis May 10, 2010 at 01:57

This was a really great Railscast highlighting probably my favorite new feature of Rails. Thanks.


138. Ayırma Büyüsü May 12, 2010 at 07:30

Thanks for the useful code :) Its well hacked together for what I'm looking for :D

I might port it to python later :P


139. Türk Pornosu May 14, 2010 at 17:20

good nice post


140. check up May 15, 2010 at 11:28

Oh, so unexpected, so surprise! Very touching, so well written and I have some perception, learning very much. Thank you for sharing. Very happy to see these and believe that your point of view. This same time,


141. kızlık bozma May 17, 2010 at 05:40

http://talebetube.com thanks youu


142. internet marketing company May 17, 2010 at 07:13

Perfect suggestion! thank you to share your knowledge with us.


143. Kadınlara Özel May 17, 2010 at 08:41

Thank you very rich indeed a site


144. kızlık bozma May 18, 2010 at 04:06

Ben gerçekten ne mesaj için teşekkür ederiz.


145. laptop ac adapter May 18, 2010 at 22:18

I have been trying to get the named scopes to work in my model without any success.


146. bilgi May 22, 2010 at 04:22

Your site is very nice touches on a beautiful subject


147. Soğutma Büyüsü May 24, 2010 at 08:37

good post.


148. 上海 ホームページ制作 May 24, 2010 at 23:29

Thanks for this great resource page! May I request that you attempt to place freelance blogs according to geographic origins, so people w


149. レンタカー 格安 May 25, 2010 at 02:26

I think you are referring to "black snake moan"..It stars Samuel L. Jackson and Christ


150. 网站建设 May 26, 2010 at 01:22

I think you are referring to "black snake moan"..It stars Sa


151. bocek ilaclama May 27, 2010 at 07:53

thank


152. vlad May 27, 2010 at 12:45

that was most excellent.


153. MBT NFL JARDON AIR MAX GHD Jun 01, 2010 at 01:51

It's great to see an article like this. www.mbtselling.com www.jerseystown.com www.dunkjordan.com www.airmaxsupplier.com www.ghdbeautyhair.com


154. spor Jun 01, 2010 at 08:12

it's too important, thanks...


155. Fat Burning Furnace Jun 02, 2010 at 22:24

I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.


156. Fat Burning Furnace Jun 03, 2010 at 01:51

I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.


157. ayakkabı modelleri Jun 04, 2010 at 08:59

I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.


158. bilgi Jun 06, 2010 at 10:34

Your site is very nice touches on a beautiful subject


159. Cinsel Sohbet Jun 06, 2010 at 12:00

danke :D


160. cam mozaik Jun 07, 2010 at 10:40

Thanks a lot! I am just learning Information of Subject.
Php and this was very easy to follow and helped a lot.
You really took time to explain every little bit.
Thanks again


161. cam mozaik Jun 09, 2010 at 05:12

Thank you for inquiring. Been working very nice.
An excellent blog about perfect.
Thank's again.


162. porno Jun 09, 2010 at 22:11

I have been using edge rails as of late just for this amazing functionality. In addition to the new level of dynamism this feature adds to Rails, it also adds such simplicity.


163. ajans Jun 09, 2010 at 22:11

I am always been a great fan of your railscast. Keep up the good works.


164. Chicago mover Jun 10, 2010 at 00:25

"railscasts"- Great article and thanks for posting.You are one of my favourite site.You will always be in my bookmarks.


165. ghd Jun 10, 2010 at 19:53

very interesting point.thanks for sharing,bro!dd


166. ghd glätteisen Jun 10, 2010 at 19:54

"railscasts"- Great article and thanks for posting.You are one of my favourite site.You will always be in my bookmarks.


167. ood chipper Jun 10, 2010 at 19:59

<a href="http://www.ghd-straightener.com.au" target="_blank">ghd straightener</a>
<a href="http://www.ghd-straightener.com.au" target="_blank">ghd hair straightener</a>


168. Famous Footwear Coupons Jun 13, 2010 at 02:11

this is a great post


169. Swiffer Coupons Jun 13, 2010 at 02:13

nice post there


170. Magazin Jun 13, 2010 at 02:25

Cool. Talking about makes sense. Is recognized. Hope that it will often share such a good text. I will


171. Justin Bieber Jun 13, 2010 at 02:26

i'm new, how can i see generated queries like you do in the bottom terminal ?


172. Gsm Jun 13, 2010 at 02:28

I have been trying to get the named scopes to work in my model without any success. How to do next?


173. Türk Porno Jun 13, 2010 at 02:28

hey Ryan, still working on that image trouble. I'll let you know when i get it sorted out.


174. Bedding Set Jun 13, 2010 at 07:44

Hello, I arrived at this website by accident when I was exploring on Google then I came upon your web site. I have to tell you that your site is very interesting I really like your theme!


175. Christian Louboutin 2010 Jun 14, 2010 at 03:04

I am always been a great fan of your railscast. Keep up the good works.


176. cam mozaik Jun 14, 2010 at 12:40

As you have a blog about sharing was very nice.
I host it and different places in search of an active subject.
I thank you for information


177. cam mozaik Jun 15, 2010 at 07:54

Thanks a lot! I am just learning Information of Subject.
Php and this was very easy to follow and helped a lot.
You really took time to explain every little bit.
Thanks again...


178. Kişisel Blog Jun 15, 2010 at 13:43

I agree with you, good luck.


179. pci-e modems Jun 18, 2010 at 20:16

Very interesting screencast ! Cool new feature ! Thanks for this tip !


180. tup bebek Jun 21, 2010 at 06:48

a very successful site. Also very revealing article. Thanks to the contributors.


181. ankara escort Jun 22, 2010 at 06:52

HOLA ME GUSTA MUCHO BRASIL POR QE HOY CHICOS LINDOS BYE MARIANA DE PERU


182. parça kontör Jun 22, 2010 at 13:22

good luck


183. kızkık bozma Jun 24, 2010 at 13:55

Your site is very nice touches on a beautiful subject


184. sikis izle Jun 24, 2010 at 13:57

Thank you,I think it's very useful.


185. jowry Jun 25, 2010 at 00:29

this definitely lowers the need to create custom "self.find..." methods. However I would hesitate getting too fancy here. If you have a complicated search which needs to dynamically build up the conditions based on the passed parameters, then I wouldn't use named_scope for this.


186. lezbiyenler Jun 26, 2010 at 10:13

Thank you very much.


187. free high school diploma Jun 28, 2010 at 09:13

Great information, thank you very much.


188. islami sohbet Jun 28, 2010 at 13:29

thanx


189. acar Jul 01, 2010 at 04:14

thank you ... :)


190. esenyurt Jul 05, 2010 at 15:00

thenk you for admin...


191. facebook sexbook Jul 06, 2010 at 06:05

great stuff i'm using scopes


192. Gucci Shop Jul 07, 2010 at 00:09

Your aritcle is very helpful for me,good job!


193. becerixiz Jul 07, 2010 at 13:06

thanks


194. klip18 Jul 07, 2010 at 13:07

thanks


195. Internet Marketing Product Reviews Jul 09, 2010 at 12:44

great job guys


196. wenjing Jul 13, 2010 at 19:59

How wonderful your article is!


197. wenjing Jul 13, 2010 at 20:00

Thanks for share!


198. wenjing Jul 13, 2010 at 20:03

What a nice article!


199. film indir Jul 14, 2010 at 03:19

These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post, writing is simply great, thank you for the post


200. Naturally Increase Metabolism Jul 16, 2010 at 11:03

This is something I was completely unaware of. Thanks for posting.


201. sikişme sahneleri Jul 17, 2010 at 14:29

Thank you good post. very nice


202. sikiş hikayeleri Jul 17, 2010 at 14:30

If they post a comment, and it is on topic, be glad someone saw your blog and thought enough to post to it


203. kerhane Jul 17, 2010 at 14:30

I wonder if these named scopes can be used in conjunction within existing search plugins like acts_as_ferret in one line


204. Texas Mesothelioma Attorneys Jul 21, 2010 at 21:42

First time i have visited this site.I have read this blog,i noted that there are mostly good points which increase the importance of the blog.Nice work.Keep it up to write more good information.
<a href="http://www.wikipeers.com/legal/4327-Recover-Yourselves-by-Seeking-Mesothelioma-Attorneys-Texas.html">Mesothelioma Attorneys Texas</a>


205. notebook tamir Jul 23, 2010 at 06:12

thanks admin... very good...


206. parça kontör Jul 25, 2010 at 01:00

I was completely unaware of. Thanks for posting. :)


207. Fat Burning Furnace Jul 25, 2010 at 04:04

Thanks!


208. jordans shoes Jul 25, 2010 at 22:46

 I love your post, thank you for sharing.


209. colts jerseys Jul 26, 2010 at 00:44

Thank you for sharing.


210. steelers shop Jul 26, 2010 at 00:49

 Hi, where did you get this information can you please support this with some proof or you may say some good reference as I and others will really appreciate. This information is really good and I will say will always be helpful if we try it risk free. So if you can back it up. That will really help us all. And this might bring some good repute to you.


211. Arac Kiralama Jul 26, 2010 at 02:42

great article from you my friend


212. saglik haberleri Jul 28, 2010 at 04:52

so good page.. thanks admin.


213. wholesale digital camera charger Jul 30, 2010 at 21:33

This article is very interesting. Thank you very much for sharing .


214. pll fm transmitter Jul 30, 2010 at 22:46

These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post, writing is simply great, thank you for the post


215. kombi fiyatları Jul 31, 2010 at 10:02

The contents of the article drew my attention and so I wanted to thank you for enlighten me with an expression so well. I wish you continued sharing. Good work


216. Start Sharing Not Selling Aug 02, 2010 at 04:34

Hi Admin, Me & my fellow classmates use your blogs as our reference materials. We look out for more interesting posts from your end about the same topic . Even the future updates about this topic would be of great help.


217. Sanal Şirket Aug 02, 2010 at 11:17

Published because of the useful information I know, thank you. You have given us your valuable comments I wish you continued thanks to informative content


218. dantel modelleri Aug 02, 2010 at 15:37

thank you wry nice


219. frikik resimleri Aug 02, 2010 at 15:37

thnk good


220. tüp bebek Aug 03, 2010 at 03:49

very best posted thank you and cong..


221. UGG Classic Argyle Knit Aug 03, 2010 at 21:46

  Great!This article is creative,there are a lot of new idea,it gives me inspiration.I think I will also inspired by you and think about more new ideas


222. Lower Cholesterol Aug 04, 2010 at 07:49

Great information. Interesting new features. Thanks for posting.


223. About Healing Aug 05, 2010 at 22:32

Good post. I can barely follow it.


225. strapping machinery Aug 06, 2010 at 18:57

Thanks for sharing the information.It is definitely going to help me some time.


226. shrink wrap Aug 06, 2010 at 18:57

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the excellent work.


226. ghd straightener Aug 07, 2010 at 00:07

ghd


227. fbml kodları Aug 07, 2010 at 02:42

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the excellent work.


228. gabattery Aug 09, 2010 at 02:32

Thanks for a great post! My attention tends to drift after about 7 minutes, so i'll have to come back and watch again a couple times


229. Sanalalemci Aug 09, 2010 at 06:33

Thank you..


230. replacement battery charger Aug 10, 2010 at 00:26

Thanks for a great post!


231. Jeff Smith Aug 10, 2010 at 08:42

Great job here guys. Keep the great posts coming. I follow your blog and I follow you on Twitter.


232. sohbet siteleri Aug 10, 2010 at 14:36

thnnnxx all of you


233. seo company london Aug 11, 2010 at 06:16

So many of us know how cool named_scopes are in ActiveRecord; they really make building complex queries quite pleasant compared to writing out big hairy SQL strings all over the place. However, in the past week as I have refactored my whole web application to use this excellent feature, I've run into some little-discussed items that I feel should be shared somewhere. Hope you enjoy, and anybody who is more advanced in their Rails-fu is welcome to give me some schooling as to where I've gone wrong on any of these, as most of my discoveries here are through trial and error.


234. air jordans shoes Aug 11, 2010 at 19:53

<a href="http://www.kicksbar.com" title="air jordans shoes">air jordans shoes</a>


235. free directory list Aug 11, 2010 at 22:27

Keep it short and simple. This is what you do!


236. emrah eren Aug 13, 2010 at 17:28

thanks


237. replica nfl jerseys Aug 13, 2010 at 18:42

 lots of good advice on your post. and as a return,i will buy a Cheap nfl jerseys to you for my thanking.


238. cheap jordan sneakers Aug 16, 2010 at 00:25

<a href=http://www.kicksbar.com>cheap jordan sneakers</a>Welcome to visit our company website:http://www.kicksbar.com


239. air jordans sneakers Aug 16, 2010 at 00:28

<a href=http://www.kicksbar.com>air jordans sneakers</a>Adrian: “Our response was: With PHP people learn that because they want to get jobs. With Java they learn that because they take computer science courses. With Python you learn it because you love it. Because you want to experience the beauty. I’m sure it’s the same way for Ruby. If I’m hiring a Python programmer the chances are that the person is good.”
David: “I totally agree.”


240. jordan air force one Aug 16, 2010 at 00:30

<a href=http://www.kicksbar.com>jordan air force one</a>
michael jordan sneakers
new jordan sneakers
cheap jordan sneakers
air jordans sneakers


241. jordan shoe Aug 16, 2010 at 00:32

<a href=http://www.kicksbar.com>jordan shoe</a>Ruby on Rails


242. World News Aug 16, 2010 at 08:49

Thanks for a great post! My attention tends to drift after about 7 minutes, so i'll have to come back and watch again a couple times


243. Deneme Aug 16, 2010 at 15:52

Thanks


244. jordan af1 Aug 16, 2010 at 17:58

<a href=http://www.kicksbar.com>jordan af1</a>jordan af1


245. jordan air force 1 Aug 16, 2010 at 18:11

<a href=http://www.kicksbar.com>jordan air force 1</a>jordan air force 1
cheap jordan sneakers
air jordans sneakers


246. new jordan sneakers Aug 16, 2010 at 18:17

<a href=http://www.kicksbar.com>new jordan sneakers</a>new jordan sneakers


247. jordans sale Aug 16, 2010 at 18:23

<a href=http://www.kicksbar.com>jordans sale</a>


248. Affiliate Dot Com Aug 17, 2010 at 13:26

I had no idea this was the way it was. I have now changed my views.


249. cheap hair staighteners Aug 18, 2010 at 02:50

Yes,it’s good recently.


250. vibram five finger shoes Aug 18, 2010 at 02:51

happy to here


251. Naturally Increase Metabolism Aug 18, 2010 at 06:48

Very informative information.


252. Naturally Increase Metabolism Aug 18, 2010 at 06:50

You need to naturally increase your metabolism to succeed at dieting


253. How to Lower Cholesterol Aug 18, 2010 at 06:52

How you can lower cholesterol without the side effects of harsh medications


254. Best Acai Supplement Aug 18, 2010 at 06:53

What is the best acai supplement for you?


255. How to Lower Cholesterol Aug 18, 2010 at 06:55

Learn How to Lower Cholesterol With Diet


256. maroclin Aug 18, 2010 at 09:10

it is so great and i will be back to read ti again.nice


257. olympus li-40b charger Aug 18, 2010 at 19:02

It is Very informative information.


258. wariror Aug 18, 2010 at 21:44

hello thank you admin


259. Şarkı Sözü Aug 19, 2010 at 07:36

I am always been a great fan of your railscast. Keep up the good works.


260. nike air max 2009 Aug 19, 2010 at 11:54

i agree with your point it very useful articles


261. trade show booths Aug 20, 2010 at 05:54

Hi, this is very nice posting, I enjoyed it a lot and I think other readers might enjoy it as well.


262. asya Aug 20, 2010 at 06:14

çok başarılı paylaşıma açık bir site olmuş başarılarınızın ve çalışmalarınızın devamını dilerim elinize emeginize saglık


263. ucuz tatil Aug 20, 2010 at 06:20

I am always been a great fan of your railscast. Keep up the good works.


264. tatil yerleri Aug 21, 2010 at 05:35

Merhabalar Web siteniz çok güzel. Zaten ziyaretçi defterinizdeki mesajlarda bunu gösteriyor. Emeği geçen herkesin ellerine sağlık


265. How to Lower Cholesterol Aug 21, 2010 at 07:22

What Can be Done to Lower Cholesterol Without the Use of Medication and the Side Effects They Produce?


266. eforush Aug 22, 2010 at 01:26

Thanks For Your Job. Its Very Interesting for me. Im eforush from kasablanka


267. medyum Aug 22, 2010 at 02:56

The information you provided was very useful. Because of your help, thank you


268. medyum Aug 22, 2010 at 05:19

The information you provided was very useful. Because of your help, thank you


269. air max nike shoes Aug 22, 2010 at 07:26

good and perfect1


270. nike lebron vii shoes Aug 22, 2010 at 07:27

LeBron's story is always associated with progress and victory.


271. diyetisyen Aug 23, 2010 at 07:04

The information you provided was very useful. Because of your help, thank you


272. ffxiv gil Aug 24, 2010 at 00:34

cool


273. ffxiv cd key Aug 24, 2010 at 00:36

thanks for sharing


274. ffxiv key Aug 24, 2010 at 00:37

thank you


275. Watch Video Aug 24, 2010 at 01:24

Your site is very nice touches on a beautiful subject


276. Fenerbahçe Paok canlı izle Aug 24, 2010 at 01:25

Fenerbahçe Paok canlı izle


277. health Aug 24, 2010 at 06:01

The information you provided was very useful. Because of your help, thank you


278. gpbattery Aug 24, 2010 at 18:03

Wow, this looks really cool. I especially like the efficiency of the generated SQL query when you concatenated the named_scopes. Really amazing and definately a great feature for bigger, data-filled applications.

Thanks for another great screencast!


279. digital camera battery Aug 24, 2010 at 18:06

The information you provided was very useful. Because of your help, thank you


280. authentic nike shoes Aug 24, 2010 at 22:55

Interesting article, Funny comment. Keep it up! I was just wondering how to pull this off. I'm guessing some clients probably want a mobile version for their site and so I'm glad you posted this because I was clueless earlier.


281. XMZS22 Aug 25, 2010 at 23:32

Throughout the 20th century, 80s, beyond the Jordan of basketball, it began to [url=http://www.discount-kicks.com/]cheap jordans[/url] and budding hip-hop icon. Basketball star and a common cultural features street musicians: rebellious, full of contempt between mainstream culture and provocative behavior.
[url=http://www.discount-kicks.com/]air max 2009[/url] was released in 2009, it sold well because all of the Nike brand in the world. The improved max air cushion technology was first used him in the [url=http://www.discount-kicks.com/]air max 2010[/url] air cushion crystal clear that the whole sole of the foot so this shoe is more visual impact.


282. tedavi Aug 26, 2010 at 04:28

sitenizi çok iyi buldum bilgiler her zaman işimize yarayabiliyor ama okumayı sevdiğimiz için daha fazla yazı koyasanız sevinirim.iyi çalışmalar.


283. Kittie Risewick Aug 26, 2010 at 07:17

You really took the words from my mouth.


284. altin modelleri Aug 26, 2010 at 08:08

Çok başarılı bir site olmuş. Elinize , emeğinize saglık. Başarılarınızın devamını dilerim.


285. alaxsandir Aug 26, 2010 at 21:42

thanks admin süper


286. mavigece Aug 26, 2010 at 21:43

thanks


287. louis vuitton shoes Aug 26, 2010 at 23:21

Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets


288. Wholesale Electronics Aug 27, 2010 at 00:59

Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler


289. danlod Aug 27, 2010 at 05:14

Thank you


290. sarki sözleri Aug 27, 2010 at 19:03

s.a. yeni siteniz hayırlı olsun. inşallah güzel çalışmaların yapılacağı ve duyurulacağı bir buluşma noktası olur temennisiyle..


291. nike air max 2009 Aug 28, 2010 at 04:45

i agree with your point it very useful articles


292. How to Lower Cholesterol Aug 28, 2010 at 08:06

Great information.


293. vibram five fingers Aug 29, 2010 at 23:34

Really trustworthy blog. Please keep updating with great posts like this one. I have booked marked your site and am about to email it to a few friends of mine that I know would enjoy reading..


294. serhan Aug 30, 2010 at 17:25

tnx


295. snow boots Aug 31, 2010 at 00:22

You shouldn't really have finds anyway as soon as you're using find conditions.


296. qwrrttyt Sep 01, 2010 at 11:30

The information you provided was very useful.


297. travel Sep 01, 2010 at 19:45

bu sıtenın kurulmasında emegı gecen tum yetkılılere sonsuz tesekkur ederım...


298. levis belts Sep 01, 2010 at 21:01

Good article! Thank you so much for sharing this post.Your views truly open my mind.

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player
Give Back to Open Source