Problems with rails3.0.0.rc and haml?

Hi there,

I have a Rails application I developed using Rails 3.0.0.beta4. Up
until now no views were needed. My controllers just rendered text and
status (webservice).

Now i needed my first UI, i upgraded to rails 3.0.0.rc and i am for
the first time working with haml.

When i go to my first view, i get this very weird error:

wrong number of arguments (2 for 0)

The full trace:

activesupport (3.0.0.rc) lib/active_support/callbacks.rb:93:in send' activesupport (3.0.0.rc) lib/active_support/callbacks.rb:93:inrun_callbacks’
actionpack (3.0.0.rc) lib/abstract_controller/callbacks.rb:17:in
process_action' actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb: 30:inprocess_action’
activesupport (3.0.0.rc) lib/active_support/notifications.rb:52:in
instrument' activesupport (3.0.0.rc) lib/active_support/notifications/ instrumenter.rb:21:ininstrument’
activesupport (3.0.0.rc) lib/active_support/notifications.rb:52:in
instrument' actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb: 29:inprocess_action’
actionpack (3.0.0.rc) lib/action_controller/metal/rescue.rb:17:in
process_action' actionpack (3.0.0.rc) lib/abstract_controller/base.rb:105:inprocess’
actionpack (3.0.0.rc) lib/abstract_controller/rendering.rb:40:in
process' actionpack (3.0.0.rc) lib/action_controller/metal.rb:133:indispatch’
actionpack (3.0.0.rc) lib/action_controller/metal/rack_delegation.rb:
14:in dispatch' actionpack (3.0.0.rc) lib/action_controller/metal.rb:173:inaction’
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:62:in
call' actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:62:indispatch’
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:27:in
call' rack-mount (0.6.9) lib/rack/mount/route_set.rb:148:incall’
rack-mount (0.6.9) lib/rack/mount/code_generation.rb:89:in recognize' rack-mount (0.6.9) lib/rack/mount/code_generation.rb:80:inoptimized_each’
rack-mount (0.6.9) lib/rack/mount/code_generation.rb:88:in recognize' rack-mount (0.6.9) lib/rack/mount/route_set.rb:139:incall’
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:489:in
call' haml (3.0.14) lib/sass/plugin/rack.rb:41:incall’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/head.rb:14:in
call' rack (1.2.1) lib/rack/methodoverride.rb:24:incall’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/params_parser.rb:
21:in call' actionpack (3.0.0.rc) lib/action_dispatch/middleware/flash.rb:177:incall’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/session/
abstract_store.rb:149:in call' actionpack (3.0.0.rc) lib/action_dispatch/middleware/cookies.rb:268:incall’
activerecord (3.0.0.rc) lib/active_record/query_cache.rb:32:in call' activerecord (3.0.0.rc) lib/active_record/connection_adapters/abstract/ query_cache.rb:28:incache’
activerecord (3.0.0.rc) lib/active_record/query_cache.rb:12:in cache' activerecord (3.0.0.rc) lib/active_record/query_cache.rb:31:incall’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/callbacks.rb:
46:in call' activesupport (3.0.0.rc) lib/active_support/callbacks.rb:410:in_run_call_callbacks’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/callbacks.rb:
44:in call' rack (1.2.1) lib/rack/sendfile.rb:107:incall’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/remote_ip.rb:
48:in call' actionpack (3.0.0.rc) lib/action_dispatch/middleware/ show_exceptions.rb:48:incall’
railties (3.0.0.rc) lib/rails/rack/logger.rb:13:in call' rack (1.2.1) lib/rack/runtime.rb:17:incall’
activesupport (3.0.0.rc) lib/active_support/cache/strategy/
local_cache.rb:72:in call' rack (1.2.1) lib/rack/lock.rb:11:incall’
rack (1.2.1) lib/rack/lock.rb:11:in synchronize' rack (1.2.1) lib/rack/lock.rb:11:incall’
actionpack (3.0.0.rc) lib/action_dispatch/middleware/static.rb:30:in
call' railties (3.0.0.rc) lib/rails/application.rb:168:incall’
railties (3.0.0.rc) lib/rails/application.rb:77:in send' railties (3.0.0.rc) lib/rails/application.rb:77:inmethod_missing’
railties (3.0.0.rc) lib/rails/rack/log_tailer.rb:15:in call' rack (1.2.1) lib/rack/content_length.rb:13:incall’
rack (1.2.1) lib/rack/handler/webrick.rb:52:in service' /home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/ httpserver.rb:104:inservice’
/home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/
httpserver.rb:65:in run' /home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb: 173:instart_thread’
/home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:
162:in start' /home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb: 162:instart_thread’
/home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:
95:in start' /home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb: 92:ineach’
/home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:
92:in start' /home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb: 23:instart’
/home/nva/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:
82:in start' rack (1.2.1) lib/rack/handler/webrick.rb:13:inrun’
rack (1.2.1) lib/rack/server.rb:213:in start' railties (3.0.0.rc) lib/rails/commands/server.rb:65:instart’
railties (3.0.0.rc) lib/rails/commands.rb:30
railties (3.0.0.rc) lib/rails/commands.rb:27:in tap' railties (3.0.0.rc) lib/rails/commands.rb:27 script/rails:6:inrequire’
script/rails:6

I have got no clue what this means or what i am doing wrong.
I have found a few things i need to change when going from beta4 to rc
but i still can’t explain this.

It goes wrong in the callbacks, in the following function:

def run_callbacks(kind, *args, &block)
  send("_run_#{kind}_callbacks", *args, &block)
end

i have no idea why.

I hope someone can shed some light …

On Tue, Jul 27, 2010 at 11:48, nathanvda [email protected] wrote:

When i go to my first view, i get this very weird error:

wrong number of arguments (2 for 0)

That means you’re calling some function/method that’s expecting no
arguments, and you’re giving it two.

It goes wrong in the callbacks, in the following function:

def run_callbacks(kind, *args, &block)
send(“run#{kind}_callbacks”, *args, &block)
end

My guess would be that the callback is expecting no args, but is being
sent *args and &block. Even if it ignores them, it should probably
accept them. Try that and see if it works…

-Dave


Specialization is for insects. -RAH | Have Pun, Will Babble! -me
Programming Blog: http://codosaur.us | Work: http://davearonson.com
Leadership Blog: http://dare2xl.com | Play: http://davearonson.net

Well, from the log as far as i could tell: it was no where in MY code,
but everything in rails code.
So it seemed there was no easy way for me to interfere easily.

But luckily, as is often the case, the problem/bug was a stupid
mistake.

My class is called EnvelopesController, and what did i want to do with
my envelopes? send them!
Alas, defining a such-named method will cause terrible havoc! :smiley:

Stupid-stupid-stupid :slight_smile:

On Wed, Jul 28, 2010 at 02:17, nathanvda [email protected] wrote:

But luckily, as is often the case, the problem/bug was a stupid
mistake.

My class is called EnvelopesController, and what did i want to do with
my envelopes? send them!
Alas, defining a such-named method will cause terrible havoc! :smiley:

That’s the sort of thing that seems to strike Rails devs all the time.
Happened to me when I named something “options” IIRC. It seems
similar to someone’s dictum on gun handling: there are shooters who
have had accidental discharges, and shooters who will. :slight_smile:

Perhaps there ought to be a gem/plugin/whatever that will warn you if
it detects reuse of a word that Rails uses…

-Dave


Specialization is for insects. -RAH | Have Pun, Will Babble! -me
Programming Blog: http://codosaur.us | Work: http://davearonson.com
Leadership Blog: http://dare2xl.com | Play: http://davearonson.net