# Rails 2.1 and render :action

**URL:** <https://www.ruby-forum.com/t/rails-2-1-and-render-action/139230>\
**Category:** Rails\
**Created:** [June 2, 2008, 5:58am UTC](https://www.ruby-forum.com/t/rails-2-1-and-render-action/139230 "2008-06-02T05:58:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [June 2, 2008, 5:58am UTC](https://www.ruby-forum.com/t/rails-2-1-and-render-action/139230/1 "2008-06-02T05:58:44Z")

</div>

I just updated to rails 2.1 and it seems render :action with a  
relative path no longer works. I.e.,

render :action =\> ‘dosomething’

is okay, but

render :action =\> ‘…/shared/dosomething’

throws a template not found exception.

render :template =\> ‘/shared/dosomething’

works for html.erb but for .rjs.js file I get javascript exceptions  
which I don’t get with render :action.

Any suggestion appreciated.

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [June 2, 2008, 11:22am UTC](https://www.ruby-forum.com/t/rails-2-1-and-render-action/139230/2 "2008-06-02T11:22:26Z")

</div>

Hi, this error is correct because if you wanted to render an action’s  
template or any template within a controller’s action, you would do the  
following:

# Render a template associated with an action

a) render :action =\> ‘action\_name’

# Render a template

b) render :template =\> ‘controller\_name/action\_name’

In your example, ‘…/shared/dosomething’ isn’t an action but a path to a  
template file. You should not try to use a relative path or path as the  
value for the :action key. This will fail now and it was a bug before  
if it  
worked previous to 2.1. If you don’t truly know how to use a particular  
method in Rails, then I would highly recommend consulting the API:

[http://api.rubyonrails.org/](http://api.rubyonrails.org/)

Good luck,

-Conrad
