Hoopla!

now with extra whiz-bang!

Hoopla!

Simply_Helpful with nested routes hack

February 27, 2007 · 0 comments

If you've played around with Simply Helpful you've probably enjoyed just how helpful it is. That is, until you've needed to use it for nested routes. As of this post Simply Helpful is in total denial of nested routes. The form_for helper just trips over itself and sprawls across your datacenter floor if you try to use it with two objects.

I enjoy the approach that this patch takes but it didn't get committed and the code keeps on changing. Rather than attempt to chase the code with a complicated patch I've created a simple hack. Modifying a single line allows me to use SH in my nested-route-loving code.

form_helper_extensions.rb, line 21


#url         = SimplyHelpful::PolymorphicRoutes.polymorphic_url(object, self)
url         = options[:url] || SimplyHelpful::PolymorphicRoutes.polymorphic_url(object, self)

Wow. I know, it's mind-blowing. Just pass an explicit url to form for and you're all set.


<%  form_for @item, :url => item_path(@project, @item) do |f| %>
<%  end %>

→ 0 comments Tags:

undefined method 'dom_class'

February 23, 2007 · 0 comments

I've had a weird situation over here at StudioDanger headquarters with plugins going haywire. I had my app working real slick and then installed the new Engines plugin and the slickness continued unabated. A subsequent installation of the simply_helpful plugin gave me a crazy error:

"undefined method 'dom_class'"

There's this line in simplyhelpful where ActionView::Helpers::FormHelper is monkey-patched to call domclass and dom_id. These should be available because in the plugin's init.rb we see the SimplyHelpful helper injected into ActionController as a helper

require 'simply_helpful'
ActionController::Base.send :include, SimplyHelpful::RecordIdentificationHelper
ActionController::Base.helper SimplyHelpful::RecordIdentificationHelper,
                              SimplyHelpful::RecordTagHelper

At some point 'self' became an unmodified version of ActionController while simply_helpful was looking for it's special helper functions. Why did it to that? I spent three hours trying to figure it out. I have no idea.

You can patch it though. Just change domid and domclass to SimplyHelpful::RecordIdentifier.domid and SimplyHelpful::RecordIdentifier.domclass. That'll do the trick.

→ 0 comments Tags: