render '/module/controller/action' #3962

Closed
bottiger opened this Issue Dec 13, 2011 · 1 comment

Comments

Projects
None yet
3 participants

I'm working on my first rails gem, so please forgive me if this is not a real bug - but it does look very strange to me.

First of all: I'm running this on Ubuntu 11.04 [x86_64-linux], using rails 3.1.1and ruby 1.9.2p0

I have a blog_post resource and a tag resource, and I want to share templates between these two resources. They are both in the same module.

In my tags_controller I have a method like this:

def show
  @blog_posts = BlogPost.published.tagged_with(params[:id]).paginate(:page => params[:page], :per_page => 5)
  render :action => '/blog_basic/blog_posts/index'
end

but I get this error:

ActionView::MissingTemplate (Missing template blog_basic/tags/blog_basic/blog_posts/index .....

It seems like rails is ignoring the leading / in my path. Just to make sure I hadn't made a type I changed the render-line to

render :template => '/blog_basic/blog_posts/index'

And everything works as expected. If I remove the leading / in the path I get the same error - but this time for a good reason.

PS: Perhaps I should mention that /blog_basic/blog_posts/index is indeed an action in the blog_posts_controller and not just a template file.

PPS: Also, I got the whole thing working by using render :template together with :layout => true AND declaring that I want to use the default layout at the top of the tags_controller with "layout 'application'". However, I'm not sure why I needed to declare the application layout, and why the render :action did not work in the first place.

Contributor

pokonski commented Dec 13, 2011

:action parameter accepts just a name of the action, not the whole controller/action path.

drogus closed this Dec 14, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment