Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9742 (closed defect: incomplete)

Opened 2 years ago

Last modified 1 year ago

[PATCH] Namespaced view fails to find template when render is supplied with collection partial

Reported by: Si Assigned to: core
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: verified
Cc: mazzy@trix.pl

Description

With a namespaced controller, say admin::posts, view form helpers can handle the namespacing using e.g. form_for([:admin, post]), but an index.html.erb view containing:

<%= render :partial => @posts %>

will look for the posts/_post partial in the application's app/views directory instead of the app/views/admin directory.

If this is indeed the intended default, can we have a simple way to inform render of our namespacing?

<%= render :partial => [:admin, @posts] %> perhaps? (collection / object array passed as last arg)

Attachments

render_shorthand_with_namespaced_controllers_patch.diff (10.8 kB) - added by ncr on 05/08/08 11:01:05.
Ensured that patch applies and tests pass in edge (bcb090c) (May 8th 2008)

Change History

11/14/07 16:28:53 changed by jamesh

Did you ever find a solution for this?

02/13/08 21:23:20 changed by ncr

I added a patch which resolves the problem with rendering partials in namespaced controllers. The patch enchances RecordIdentifier.partial_path method - now it takes an optional controller_path argument so it is aware if the controller is namespaced. The render_partial method invokes the before-mentioned partial_path with the optional argument and renders namespaced views correctly.

Given a Nest::NestedController you can:

render :partial => @person

or

render :partial => @people

and expect the nest/people/_person to be used.

Patch includes tests and documentation update (new example).

02/13/08 23:01:34 changed by joshknowles

+1

02/14/08 14:58:27 changed by ncr

  • summary changed from Namespaced view fails to find template when render is supplied with collection partial to [PATCH] Namespaced view fails to find template when render is supplied with collection partial.

02/22/08 12:58:25 changed by mazzy

  • cc set to mazzy@trix.pl.

+1

This bug is really annoying for me. Patch works / tests pass.

03/02/08 09:45:39 changed by kamal

+1 .. I'm facing this right now, in fact

03/02/08 09:56:08 changed by ncr

  • keywords set to verified.

03/03/08 06:28:22 changed by nzkoz

  • keywords deleted.

Hey there,

we've rejigged how the partial rendering works in trunk now, could you please make sure it still applies cleanly and you're happy with the changes.

03/07/08 02:12:27 changed by lifofifo

Just wondering why did you move RenderPartialWithRecordIdentificationController. It's a bit difficult to look at the diff as those tests don't seem to be changing.

Thanks.

03/07/08 08:53:06 changed by ncr

I had to move this one controller out of its namespace (the test class) - without this change that one single test wouldn't pass. This patch makes all controllers (those in tests too of course) aware of their namespaces regarding the aspect of partial rendering and I think it was the most pragmatic to do that.

04/01/08 12:35:09 changed by stangred

  • owner changed from core to stangred.
  • status changed from new to assigned.

+1 goooood patch

04/01/08 12:42:02 changed by stangred

  • owner changed from stangred to core.
  • status changed from assigned to new.

ooops :)

04/01/08 19:51:14 changed by ncr

  • keywords set to verified.

04/05/08 11:39:38 changed by nzkoz

My only thoughts are perhaps there should be a test for something nested deeper than one directory?

05/08/08 11:01:05 changed by ncr

  • attachment render_shorthand_with_namespaced_controllers_patch.diff added.

Ensured that patch applies and tests pass in edge (bcb090c) (May 8th 2008)

05/08/08 11:02:57 changed by ncr

I've added tests for deeper nestings and ensured that attached patch applies cleanly to current edge on github.

05/08/08 11:14:18 changed by lifofifo

  • status changed from new to closed.
  • resolution set to incomplete.

Can you please create a ticket at Lighthouse and upload a patch there ?

Thanks.