#279 √ resolved
Jakub Suder

re_render_form crashes in subsite controller

Reported by Jakub Suder | October 6th, 2008 @ 03:02 PM

I have an 'admin' subsite in my project, and there's a users controller in it. When I edit a user, make a mistake and submit the form, Hobo::ModelController#re_render_form calls Controller.controller_and_view_for, which returns "admin/users" as controller name. re_render_form uses that value to create a variable name, tries to access variable "@admin/user" and throws a NameError exception.

Proposed solution: either controller_and_view_for should return a name without the subsite appended, or re_render_form should strip that part before it uses the string to create a variable name.

Comments and changes to this ticket

  • Tom Locke

    Tom Locke October 15th, 2008 @ 11:15 AM

    • → Milestone cleared.
    • → Tag changed from “controllers defect "model-controller" subsites” to “controllers defect model-controller subsites”
    • → State changed from “new” to “investigating”
    • → Assigned user changed from “” to “Tom Locke”

    Are you still seeing this with the latest hobo code?

  • Ward Vandewege

    Ward Vandewege October 16th, 2008 @ 03:43 PM

    I'm also seeing this - I'm on 0.8.3 now (it was the same with 0.8.2).

  • Ward Vandewege

    Ward Vandewege October 16th, 2008 @ 04:08 PM

    This patch seems to fix the issue for me. (Limited) testing indicates no averse effects.

    --- lib/hobo/model_controller.rb.orig 2008-10-16 11:06:28.000000000 -0400 +++ lib/hobo/model_controller.rb 2008-10-16 11:06:44.000000000 -0400 @@ -356,6 +356,7 @@

     def re_render_form(default_action)
       if params[:page_path]
         controller, view = Controller.controller_and_view_for(params[:page_path])
    
    
    •  controller.sub!(/\//, '_')
       view = default_action if view == Dryml::EMPTY_PAGE
       @this = instance_variable_get("@#{controller.singularize}")
       render :template => "#{controller}/#{view}"
      
      
  • Ward Vandewege

    Ward Vandewege October 28th, 2008 @ 09:46 PM

    This is a better formatted version of the patch

    
    --- /var/lib/gems/1.8/gems/hobo-0.8.3/lib/hobo/model_controller.rb.orig	2008-10-16 11:06:28.000000000 -0400
    +++ /var/lib/gems/1.8/gems/hobo-0.8.3/lib/hobo/model_controller.rb	2008-10-16 11:06:44.000000000 -0400
    @@ -356,6 +356,7 @@
         def re_render_form(default_action)
           if params[:page_path]
             controller, view = Controller.controller_and_view_for(params[:page_path])
    +        controller.sub!(/\//, '_')
             view = default_action if view == Dryml::EMPTY_PAGE
             @this = instance_variable_get("@#{controller.singularize}")
             render :template => "#{controller}/#{view}"
    
  • Tom Locke

    Tom Locke November 3rd, 2008 @ 04:31 PM

    • → State changed from “investigating” to “resolved”

    Finally got around to fixing this in 38d5793

    Turned out the offending line wasn't doing anything useful/sensible anyway so I just deleted it : )

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket