def self.find_for(options = {})
    scope = scoped
    scope = scope.where(:hook => options[:hook].to_s)  if options[:hook]
...

Ruby ActiveRecord query construc...

by https://www.google.com/accounts/o8/id?id=AItOawmLF7gR3CIpZoZXbwO7fiD2QWYltD3lwpM, December 23, 2010 15:27, 1 refactoring, tagged with rails, sql, activerecord, rails3, arel

Rails 3.0.3

This method ...

55502f40dc8b7c769880b10874abc9d0 Talk
# link_categories has_many links
create_table "link_categories", :force => true do |t|
  t.string   "name"
...

Ruby Find records according to r...

by https://www.google.com/accounts/o8/id?id=AItOawl_CInyr4p6Fw9fCXT3DYEGIiMyGOQDomw, August 02, 2010 18:43, 1 refactoring, tagged with rails, sql, ruby, activerecord

I have a method (LinkCatego...

55502f40dc8b7c769880b10874abc9d0 Talk
Clip.find_by_sql(["select * from clips where not exists
        (select 'clip_id' from histories where histories.clip_id = clips.id
        and histories.user_id = ?) ORDER BY clips.created_at DESC LIMIT 20", user.id])

Ruby ActiveRecord find_by_sql

by David, January 17, 2010 20:52, 5 refactorings, tagged with rails, sql, short, ruby, activerecord

How can I turn this into so...

D41d8cd98f00b204e9800998ecf8427e Talk
class Item < ActiveRecord::Base
  ALL_VOTES = "all_votes"
  SCORE = "score"
...

Ruby Complex query in Ruby on Ra...

by Pablo, January 10, 2010 13:27, No refactoring, tagged with rails, sql, ruby, activerecord, joins

I have a method called rank...

931970b8dc51b72e05e3a12b88612d61 Talk
#players = select distinct(player) from actions;
    players = repository(:default).adapter.query('select distinct(player) from actions')

...

Ruby getting 20-100+ sums in one go

by feydr.myopenid.com, February 10, 2009 19:13, 2 refactorings, tagged with sql, ruby, iteratate, sum

I have an actions table tha...

7c3536f0ffdc51a02ec2c9d1d72165d5 Talk