Forum: Ruby on Rails repond_to? bug, really strange

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
328f0bb678423fcea01ebe3b0edc74e6?d=identicon&s=25 Ben Johnson (benjohnson)
on 2008-10-15 22:33
This is really strange:

>> User.send(:merge_joins, "one", "two")
=> ["one", "two"]
>> User.respond_to?(:merge_joins)
=> false

Am I missing something here? Shouldn't the respond_to return true?

thanks for your help
8217faf2bfdfa7daf10135d41ddd421e?d=identicon&s=25 Jeff Cohen (jeff)
on 2008-10-15 23:04
(Received via mailing list)
On Oct 15, 3:33 pm, Ben Johnson <rails-mailing-l...@andreas-s.net>
wrote:
> thanks for your help
> --
> Posted viahttp://www.ruby-forum.com/.

If User is actually using method_missing to handle the merge_joins
message, then respond_to? won't be able to see it.


Jeff

purpleworkshops.com
softiesonrails.com
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-16 01:29
(Received via mailing list)
On 15 Oct 2008, at 21:33, Ben Johnson <rails-mailing-list@andreas-
s.net> wrote:

>
> This is really strange:
>
>>> User.send(:merge_joins, "one", "two")
> => ["one", "two"]
>>> User.respond_to?(:merge_joins)
> => false
>
> Am I missing something here? Shouldn't the respond_to return true?
>
By default respond_to returns false if a method is private (such as
merge_joins) but send ignores privateness and protectedness

Fred
This topic is locked and can not be replied to.