wrong number of arguments (1 for 0) | Rails | Facepalm

I am working on a simple web application to help out dieudonne and came across a seemingly random error on the rails stack while trying to build a simple email functionality. My thought process was to scaffold a “message” model and have a “send” function in the controller that would then parse the mail content using LiquidTemplating and send out the email with a delayed job process.

 

Well, all fine and dandy till I hit this error,

__define_callbacks activesupport (4.0.2) lib/active_support/callbacks.rb
364365366367368369370371372373374

      # if it was not yet defined.
      # This generated method plays caching role.
      def __define_callbacks(kind, object) #:nodoc:
        name = __callback_runner_name(kind)
        unless object.respond_to?(name, true)
          str = object.send("_#{kind}_callbacks").compile
          class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
            def #{name}() #{str} end
            protected :#{name}
          RUBY_EVAL
      end

There is no information about this out there and no one on the interwebs seems to be talking about that particular line:

str = object.send("_#{kind}_callbacks").compile

which is where unicorn says I am going wrong. Now, I know I have done no changes in the rails stack and thought maybe it was the model name and maybe I couldnt create a “message” model. So I made a “communication” model and scaffolded it. No dice.

A week later, when I decided to give it another go, I realized that I ve been inadvertently overriding the “send” method from the rails Controller class. Rename the function “send” to something else and voila, things are back to normal.

facepalm.

I wish unicorn was better at telling me the issue started at the controller and not at some point in the rails stack. oh well.

 

lOOney dOOdle

I run Engineering at Vizbee, we make SDKs to stream video from mobile devices to Smart TVs.