From 3b3798506b403911665c3c24fd055b75d6f6a44f Mon Sep 17 00:00:00 2001 From: Matt Duncan Date: Sat, 8 Aug 2009 20:10:01 -0400 Subject: Adding :from scoping to ActiveRecord calculations Signed-off-by: Michael Koziarski [#1229 state:committed] --- activerecord/test/models/organization.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/organization.rb b/activerecord/test/models/organization.rb index d79d5037c8..c85726169e 100644 --- a/activerecord/test/models/organization.rb +++ b/activerecord/test/models/organization.rb @@ -1,4 +1,6 @@ class Organization < ActiveRecord::Base has_many :member_details has_many :members, :through => :member_details + + named_scope :clubs, { :from => 'clubs' } end \ No newline at end of file -- cgit v1.2.3 From 9bb8ef9edebf5c27b8a1c67ca3776d52afbc1dc4 Mon Sep 17 00:00:00 2001 From: Rich Bradley Date: Sat, 8 Aug 2009 23:29:38 -0700 Subject: Fix for nested :include with namespaced models. [#260 state:committed] --- activerecord/test/models/company_in_module.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/company_in_module.rb b/activerecord/test/models/company_in_module.rb index 8b84c2fb5e..cdda7a44d4 100644 --- a/activerecord/test/models/company_in_module.rb +++ b/activerecord/test/models/company_in_module.rb @@ -13,7 +13,7 @@ module MyApplication has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id" has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}' - has_one :account, :dependent => :destroy + has_one :account, :class_name => 'MyApplication::Billing::Account', :dependent => :destroy end class Client < Company -- cgit v1.2.3 From 00d6c766608f90ce64f11feb98786cbc7f71b89d Mon Sep 17 00:00:00 2001 From: Gabe da Silveira Date: Sun, 9 Aug 2009 12:53:22 -0700 Subject: Enable has_many :through for going through a has_one association on the join model [#2719 state:resolved] Signed-off-by: Pratik Naik --- activerecord/test/models/author.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index b844c7cce0..f264f980d6 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -1,5 +1,6 @@ class Author < ActiveRecord::Base has_many :posts + has_many :very_special_comments, :through => :posts has_many :posts_with_comments, :include => :comments, :class_name => "Post" has_many :popular_grouped_posts, :include => :comments, :class_name => "Post", :group => "type", :having => "SUM(comments_count) > 1", :select => "type" has_many :posts_with_comments_sorted_by_comment_id, :include => :comments, :class_name => "Post", :order => 'comments.id' -- cgit v1.2.3 From 0472839d684d836e1e7ecd39722c313410d76d5b Mon Sep 17 00:00:00 2001 From: Tristan Dunn Date: Mon, 10 Aug 2009 00:41:36 +0100 Subject: Prevent overwriting of table name in merging SQL conditions [#2949 state:resolved] --- activerecord/test/models/comment.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index f7f07c103f..399dea9f12 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -1,6 +1,10 @@ class Comment < ActiveRecord::Base named_scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'" - + named_scope :for_first_post, :conditions => { :post_id => 1 } + named_scope :for_first_author, + :joins => :post, + :conditions => { "posts.author_id" => 1 } + belongs_to :post, :counter_cache => true def self.what_are_you -- cgit v1.2.3 From e06a0b03c8ba29f4b05a35560645814ac88aefbe Mon Sep 17 00:00:00 2001 From: railsbob Date: Sat, 8 Aug 2009 23:48:11 +0100 Subject: has_many :through create should not raise validation errors [#2934 state:committed] Signed-off-by: Jeremy Kemper --- activerecord/test/models/company.rb | 2 ++ activerecord/test/models/contract.rb | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 activerecord/test/models/contract.rb (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index 1c05e523e0..ab09f88a9f 100644 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -9,6 +9,8 @@ class Company < AbstractCompany validates_presence_of :name has_one :dummy_account, :foreign_key => "firm_id", :class_name => "Account" + has_many :contracts + has_many :developers, :through => :contracts def arbitrary_method "I am Jack's profound disappointment" diff --git a/activerecord/test/models/contract.rb b/activerecord/test/models/contract.rb new file mode 100644 index 0000000000..606c99cd4e --- /dev/null +++ b/activerecord/test/models/contract.rb @@ -0,0 +1,4 @@ +class Contract < ActiveRecord::Base + belongs_to :company + belongs_to :developer +end \ No newline at end of file -- cgit v1.2.3