From 74818a35432b40fef16fe74f248ea75d35405324 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 5 Mar 2011 11:56:24 -0800 Subject: use Arel::Table#alias rather than passing the :as parameter --- activerecord/lib/active_record/relation/predicate_builder.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/relation') diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 9633fd3d82..982b3d7e9f 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -5,14 +5,14 @@ module ActiveRecord table = default_table if value.is_a?(Hash) - table = Arel::Table.new(column, :engine => engine) + table = Arel::Table.new(column, engine) build_from_hash(engine, value, table) else column = column.to_s if column.include?('.') table_name, column = column.split('.', 2) - table = Arel::Table.new(table_name, :engine => engine) + table = Arel::Table.new(table_name, engine) end attribute = table[column.to_sym] -- cgit v1.2.3 From 02a43f9f4585d3c932e12b60ef23543f9c534a2e Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 12 Mar 2011 08:42:57 +0000 Subject: Resolve some TODO comments which I decided did not need anything done --- activerecord/lib/active_record/relation/query_methods.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'activerecord/lib/active_record/relation') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 0c7a9ec56d..9470e7c6c5 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -260,7 +260,6 @@ module ActiveRecord join_list ) - # TODO: Necessary? join_nodes.each do |join| join_dependency.alias_tracker.aliased_name_for(join.left.name.downcase) end -- cgit v1.2.3 From 96b9fc44000e5f40ba463ff0e893db8c4fd33b85 Mon Sep 17 00:00:00 2001 From: Iain Hecker Date: Sat, 19 Mar 2011 21:53:49 +0100 Subject: Reapply extensions when using except and only --- activerecord/lib/active_record/relation/spawn_methods.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/lib/active_record/relation') diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 4150e36a9a..128e0fbd86 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -79,6 +79,9 @@ module ActiveRecord result.send(:"#{method}_value=", send(:"#{method}_value")) end + # Apply scope extension modules + result.send(:apply_modules, extensions) + result end @@ -100,6 +103,9 @@ module ActiveRecord result.send(:"#{method}_value=", send(:"#{method}_value")) end + # Apply scope extension modules + result.send(:apply_modules, extensions) + result end -- cgit v1.2.3 From 5214e73850916de3c9127d35a4ecee0424d364a3 Mon Sep 17 00:00:00 2001 From: Josh Susser Date: Wed, 23 Mar 2011 21:52:53 -0700 Subject: add #first! and #last! to models & relations --- activerecord/lib/active_record/relation/finder_methods.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/lib/active_record/relation') diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 426000fde1..25e23a9d55 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -123,6 +123,11 @@ module ActiveRecord end end + # Same as #first! but raises RecordNotFound if no record is returned + def first!(*args) + self.first(*args) or raise RecordNotFound + end + # A convenience wrapper for find(:last, *args). You can pass in all the # same arguments to this method as you can to find(:last). def last(*args) @@ -137,6 +142,11 @@ module ActiveRecord end end + # Same as #last! but raises RecordNotFound if no record is returned + def last!(*args) + self.last(*args) or raise RecordNotFound + end + # A convenience wrapper for find(:all, *args). You can pass in all the # same arguments to this method as you can to find(:all). def all(*args) -- cgit v1.2.3