How to call render :partial properly

At some point, you may be going bananas because you're getting this error:

NoMethodError in DocumentController#new
undefined method `include?' for :new:Symbol

and the problem is that you're doing this somewhere:
render :partial => :new

instead of this:
render :partial => 'new'


This error is spawned by the method partial_pieces in /ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/partials.rb:90 which is trying to figure out if the partial you're calling is in the directory of the current controller, or some other directory. Here's that code:
89      def partial_pieces(partial_path)
90 if partial_path.include?('/')
91 return File.dirname(partial_path), File.basename(partial_path)
92 else
93 return controller.class.controller_path, partial_path
94 end
95 end

The error comes from line 90. Seems like if this were inserted at line 89.5, then this problem could be handled more gracefully
partial_path = partial_path.to_s if partial_path.is_a? Symbol

given the fuzzyness of symbols and strings, it would seem to make sense to me.

No comments: