Lauro Caetano
db5d26c9d7
Fix error when using with_options
with lambda.
...
It was causing error when using `with_options` passing a lambda as its
last argument.
class User < ActiveRecord::Base
with_options dependent: :destroy do |assoc|
assoc.has_many :profiles, -> { where(active: true) }
end
end
It was happening because the `option_merger` was taking the last
argument and checking if it was a Hash. This breaks the HasMany usage,
because its last argument can be a Hash or a Proc.
As the behavior described in this test:
https://github.com/rails/rails/blob/master/activesupport/test/option_merger_test.rb#L69
the method will only accept the lambda, this way it will keep the expected behavior. See 9eaa0a34
2014-04-03 10:26:37 -03:00
Jeremy Kemper
6f08440538
Explicit dependency on Hash#deep_merge extension
2009-03-28 23:52:46 -07:00
David Heinemeier Hansson
9eaa0a3449
Added lambda merging to OptionMerger (especially useful with named_scope and with_options) [ #740 state:committed] (Paweł Kondzior)
2008-11-15 16:48:14 +01:00
Jeremy Kemper
a1eb4e11c2
Get rid of 'Object#send!'. It was originally added because it's in Ruby 1.9, but it has since been removed from 1.9.
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Conflicts:
actionpack/test/controller/layout_test.rb
2008-08-31 13:20:15 -07:00
Lawrence Pit
40dbebba28
Allow deep merging of hash values for nested with_options. [ #490 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-07-17 01:59:08 +01:00
Jeremy Kemper
053d057a88
send -> send! for some private methods
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7659 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-09-27 10:41:12 +00:00
Jeremy Kemper
041b9b8a1c
Some 1.9 forward compatibility
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7474 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-09-14 00:34:43 +00:00
Rick Olson
d6925b14fa
Don't undefine #class in OptionMerger [Rick]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5197 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-09-27 18:46:46 +00:00
Marcel Molina
71ff705449
Allow default options in with_options to be overridden. Closes #4480 . [murphy@cYcnus.de]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4282 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-26 21:49:41 +00:00
Sam Stephenson
85fe1ecaef
Add Object#with_options for DRYing up multiple calls to methods having shared options
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3314 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-12-15 20:03:23 +00:00