diff options
author | John Mileham <jmileham@gmail.com> | 2011-03-24 15:03:08 -0400 |
---|---|---|
committer | John Mileham <jmileham@gmail.com> | 2011-03-24 15:03:08 -0400 |
commit | b44a0ec153c84384e9b97a069e81f28bc5c2a4bf (patch) | |
tree | 94713aff0c241f91530dfd714bf685019c84ccab /activerecord/lib/active_record/relation | |
parent | d5994ee48af14d67f0eec7d23863d4b19211b078 (diff) | |
parent | 5214e73850916de3c9127d35a4ecee0424d364a3 (diff) | |
download | rails-b44a0ec153c84384e9b97a069e81f28bc5c2a4bf.tar.gz rails-b44a0ec153c84384e9b97a069e81f28bc5c2a4bf.tar.bz2 rails-b44a0ec153c84384e9b97a069e81f28bc5c2a4bf.zip |
Merge branch 'master' of github.com:rails/rails into count_behavior
Diffstat (limited to 'activerecord/lib/active_record/relation')
4 files changed, 19 insertions, 3 deletions
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 <tt>find(:last, *args)</tt>. You can pass in all the # same arguments to this method as you can to <tt>find(:last)</tt>. 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 <tt>find(:all, *args)</tt>. You can pass in all the # same arguments to this method as you can to <tt>find(:all)</tt>. def all(*args) 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] diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index cd1d7108b3..9470e7c6c5 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -261,7 +261,7 @@ module ActiveRecord ) join_nodes.each do |join| - join_dependency.table_aliases[join.left.name.downcase] = 1 + join_dependency.alias_tracker.aliased_name_for(join.left.name.downcase) end join_dependency.graft(*stashed_association_joins) 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 |