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
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
How can I turn this into so...
1 2 3 4
class Item < ActiveRecord::Base ALL_VOTES = "all_votes" SCORE = "score" ...
Ruby Complex query in Ruby on Ra...
I have a method called rank...
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...
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...
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...
What's the best way to save...
1 2 3 4
require 'rubygems' require 'active_record' require 'benchmark' ...
Ruby ActiveRecord threaded bench...
first of three benchmarks, ...
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...
I know there has to be a "r...
1 2 3 4
def which_class? if self.language == "C/C++" self.language = "sh_cpp" ...
Ruby class picker
language is a column in a c...
For a object (e.g. user), I...