def send Considered Harmful (FAILSAFE error)

Posted on January 19, 2008
If your rails app mysteriously breaks just after adding some new functionality, with an error message like:
Processing MessagingController#inbox (for 192.168.1.100 at 2008-01-19 11:02:45) [GET]
  Session ID: 17db90c03c03ebfee0c3ae4198900706
  Parameters: {"action"=>"inbox", "controller"=>"messaging"}
/!\ FAILSAFE /!\  Sat Jan 19 11:02:45 MST 2008
  Status: 500 Internal Server Error
  wrong number of arguments (1 for 0)

Chances are you just added a method “send” or similar to your rails app:

class MessagingController < AuthenticatedController
  def send
  end
end

This would, of course, override ruby’s default “send” behavior (an integral part of ruby, and rails).

Hat tip, Justin Ball – thx!

Comments
  1. Magnus HolmJanuary 19, 2008 @ 11:51 AM

    Why doesn’t Rails use send in stead of send?

  2. MichaelJanuary 19, 2008 @ 02:30 PM

    I just finished up an app that has messaging. Originally I had it as MessagingController#deliver but I changed it over to be more RESTful so now it is MessagesController#create.

  3. Jeremy McAnallyJanuary 19, 2008 @ 08:42 PM

    @Magnus: It’s not Rails’ fault; Ruby has a send method for every object to arbitrarily send methods to them. For example, try this: “this is a Hash object”.send(:gsub, /Hash/, “String”)

  4. DanJanuary 20, 2008 @ 03:27 PM

    I think Magnus was talking about the _ send _ (double underscore, send, double underscore in case that doesn’t render right) method.