rails/rails — pull request #17413 by janraasch (2014-10-28 08:33:36+00:00)
Title: Add (failing) test for `:some_method.to_proc`-type callback filter

Currently this yields an `ArgumentError: no receiver given` error due to
the transformations done to the filter proc in `ActiveSupport::Callbacks::Callback#make_lambda`

This behaviour originates from
https://github.com/rails/rails/commit/6189e2714b730d4ae0da11884b8082cbee0fb44c#diff-1ecd313ff0ab827af30014553cf8918dR356

Probably debatable if this is a problem, since people could just use `:some_method` as the filter. However, when/if one runs into this, it does seem pretty strange and it is hard to understand the root of the problem.

One would guess that e.g.

```ruby
validates :something, if: proc {|x| x.should_validate?}
```

behaves the same as

```ruby
validates :something, if: proc(&:should_validate?)
```

or

```ruby
validates :something, if: :should_validate?.to_proc
```

The latter two both yield the `ArgumentError: no receiver given` in https://github.com/rails/rails/blob/master/activesupport/lib/active_support/callbacks.rb#L441.

What do you think? A fix would probably further complicate the `ActiveSupport::Callbacks::Callback#make_lambda` method.