Wrong number of arguments error

43 views
Skip to first unread message

Dean

unread,
Sep 5, 2012, 8:54:04 PM9/5/12
to hobo...@googlegroups.com
I'm doing some maintenance on an old Hobo 1.0.1 application and as part of the process bringing it up to 1.1.0.  In trying to get the development environment running I've run up against a weird problem - the first page load works fine but all subsequent pages fail, including the successful page if I reload it.  If I restart webbrick then I can load another page but again all subsequent requests fail.

The error reported is:

Processing SitesController#show (for 127.0.0.1 at 2012-09-06 09:51:04) [GET]
  Parameters: {"controller"=>"sites", "action"=>"show", "id"=>"419-nad034"}
  Site Load (0.8ms)   SELECT * FROM `sites` WHERE (`sites`.`id` = 419) ORDER BY `sites`.code
  SQL (0.7ms)   SHOW TABLES
Rendering sites/show

ActionView::TemplateError (wrong number of arguments (2 for 1)) on line #1 of app/views/sites/show.dryml:
1: <show-page>
2:   <append-scripts:>
3:     <%= GMap.header %>
4:   </append-scripts:>

    app/views/sites/show.dryml:1:in `render'
    app/views/sites/show.dryml:1:in `_run_dryml_app47views47sites47show46dryml'
    dryml (1.1.0) lib/dryml/template_handler.rb:108:in `render'
    dryml (1.1.0) lib/dryml/template_handler.rb:83:in `render_for_file'
    hobo (1.1.0) lib/hobo/model_controller.rb:821:in `render'
    hobo (1.1.0) lib/hobo/controller.rb:23:in `call'
    hobo (1.1.0) lib/hobo/controller.rb:23:in `included_in_class'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'


I have updated all of the gems to 1.1.0 and their dependencies but haven't modified any of the 1.0.1 code yet. 

I'm pretty stumped by this. Any suggestions where to start looking?

Thanks,

Dean

Bryan Larsen

unread,
Sep 5, 2012, 9:03:32 PM9/5/12
to hobo...@googlegroups.com
Wow, that's weird. According to your backtrace, it appears to be
thinking that your file isn't DRYML. Once it's made that decision,
it's not surprising that it's going to die horribly.

Would it be possible for you to send me a tarball so I can dive into your code?

cheers,
Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/isaNxdKtZeMJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

Dean

unread,
Oct 4, 2012, 12:43:56 PM10/4/12
to hobo...@googlegroups.com

I've done a bit of tracing on this and tracked the problem down the following code in dryml/template_handler.rb

class ActionView::Template
 
  def render_with_dryml(view, local_assigns = {})
    if handler == Dryml::TemplateHandler
      render_dryml(view, local_assigns)
    else
      render_without_dryml(view, local_assigns)
    end
  end
  alias_method_chain :render, :dryml

The weird thing is that handler == Dryml::TemplateHandler evaluates as true on the first render, but evaluates to false on all subsequent renders - even though, according to the debugger, the handler method returns Dryml::TemplateHandler each time.

Even more confusing is that the debugger reckons that the expression evaluates to false on the second render.

The only difference I can see is that as handler is memoized, the first call calls the method whereas the second call returns the cached result.  However, the debugger says that the memoized value of handler is a class of Dryml::TemplateHandler



Possibly it is something to do with my environment?

$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.14)
actionpack (2.3.14)
activerecord (2.3.14)
activeresource (2.3.14)
activesupport (2.3.14)
dryml (1.1.0)
hobo (1.1.0)
hobofields (1.1.0)
hobosupport (1.1.0)
mysql (2.8.1)
rack (1.1.3)
rails (2.3.14)
rake (0.9.2.2)
sqlite3 (1.3.6)
validates_existence (0.5.2)
will_paginate (2.3.15)

$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

Any ideas?

Dean

Bryan Larsen

unread,
Oct 4, 2012, 1:12:52 PM10/4/12
to hobo...@googlegroups.com
Can you try downgrading to Hobo 1.0?   Hobo 1.1 was kind of a dead end -- it was released simultaneously with Hobo 1.3 so wasn't widely used.  And the area of code that you're highlighting is the biggest difference between 1.0 & 1.1.

cheers,
Bryan


--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/wnTDl322bLAJ.

Matt Jones

unread,
Oct 4, 2012, 2:34:04 PM10/4/12
to hobo...@googlegroups.com

On Oct 4, 2012, at 12:43 PM, Dean wrote:

> I've done a bit of tracing on this and tracked the problem down the following code in dryml/template_handler.rb
>
> class ActionView::Template
>
> def render_with_dryml(view, local_assigns = {})
> if handler == Dryml::TemplateHandler
> render_dryml(view, local_assigns)
> else
> render_without_dryml(view, local_assigns)
> end
> end
> alias_method_chain :render, :dryml
>
> The weird thing is that handler == Dryml::TemplateHandler evaluates as true on the first render, but evaluates to false on all subsequent renders - even though, according to the debugger, the handler method returns Dryml::TemplateHandler each time.
>

I've hit this sort of thing a lot in development mode - the problem is that something is reloading the Dryml module. The net result is that objects left behind from *before* the reload look like they're the right class, but they actually point to a different object (thus failing the comparison). A quick example in the console:

Loading development environment (Rails 3.2.8)
[1] pry(main)> User.object_id
=> 2151798380
[2] pry(main)> reload!
Reloading...
=> true
[3] pry(main)> User.object_id
=> 2173205700
[4] pry(main)> ActiveRecord::Base.object_id
=> 2181548000
[5] pry(main)> reload!
Reloading...
=> true
[6] pry(main)> ActiveRecord::Base.object_id
=> 2181548000
[7] pry(main)>


(replace 'User' with any model, or really any class reloaded by reload!)

Note that ActiveRecord::Base doesn't change it's object_id, but the model does.

No idea how to fix this, but it at least makes sense *why* it's happening now.

--Matt Jones

Dean

unread,
Oct 5, 2012, 8:38:31 AM10/5/12
to hobo...@googlegroups.com
Going back to Hobo 1.0.3 has things working again.
Reply all
Reply to author
Forward
0 new messages