1 2 3 4
# 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, ruby, activerecord, sql
1 2 3 4
class Activity < ActiveRecord::Base has_and_belongs_to_many :products has_and_belongs_to_many :articles ...
Ruby find_by in two has_and_belo...
Using: Article.first.products
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,
2 refactorings, tagged with model, assoziations, activerecord, rails activerecord
For a object (e.g. user), I...
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...
by Kevin Williams,
February 20, 2008 04:33,
No refactoring, tagged with orm, activerecord, benchmark
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...
I have a method (LinkCatego...