1
2
3
4
# Associations
#
# User: has_many :sources, :as => :sourceable, :dependent => :destroy
...

Ruby Get child elements from a o...

by Chris, March 11, 2010 08:27, No refactoring, tagged with model, assoziations, activerecord, rails activerecord

For a object (e.g. user), I...

5d7c8b8f2de06c07b2bf0848d20ce71f Talk
1
2
3
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 activerecord, rails, ruby, sql, short

How can I turn this into so...

Avatar Talk
1
2
3
4
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 ruby, rails, joins, activerecord, sql

I have a method called rank...

931970b8dc51b72e05e3a12b88612d61 Talk
1
2
3
4
class User < ActiveRecord::Base
  has_many :assets, :foreign_key => 'creator_id'

...

Ruby Change a finder method w/ p...

by saizai.livejournal.com, June 06, 2009 00:16, No refactoring, tagged with rails, activerecord, associations, named_scope

How do I turn this into a h...

237338834f2f8948e862e91392a8c1b4 Talk
1
2
3
4
if @chosen_campaign.network.nil?
  case params[:type]
  when "moderated"
...

Ruby 2 Crossed conditions for Ac...

by gkochan.myopenid.com, April 16, 2009 14:24, -1 refactorings, tagged with activerecord, find, crossed conditions

I can't figure out any nice...

A0317a752d14a9ba201370824cea5815 Talk
1
2
3
4
    if @foo.update_attributes(params[:foo]) and @foo.bar.update_attributes(params[:bar])
      redirect_to foo_url(@parent)
    else
...

Ruby Saving multiple models in o...

by rafeco, July 29, 2008 15:56, 2 refactorings, tagged with rails, activerecord, controller

What's the best way to save...

Df2e97f18b5802e199d4920552a52d34 Talk
1
2
3
4
require 'rubygems'
require 'active_record'
require 'benchmark'
...

Ruby ActiveRecord threaded bench...

by Kevin Williams, February 20, 2008 04:33, 1 refactoring, tagged with orm, activerecord, benchmark

first of three benchmarks, ...

267942571862781dd912de6482a35f46 Talk
1
2
3
4
  def planned_percent_complete
    if self.planned_complete_in_dollars != nil
      (( self.planned_complete_in_dollars.to_f / self.task.budget.to_f )  * 100).round(2)
...

Ruby Same methods, different Act...

by Chris W., January 08, 2008 18:31, 6 refactorings, tagged with ruby, rails, activerecord, dry

I know there has to be a "r...

Avatar Talk
1
2
3
4
def which_class?
  if self.language == "C/C++"
     self.language = "sh_cpp"
...

Ruby class picker

by Garrett, December 10, 2007 00:04, 8 refactorings, tagged with ruby, rails, activerecord, model

language is a column in a c...

E9674d02c33d1d711a462026f40bbaf4 Talk