Rails 2.1 and render :action

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.

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/

Good luck,

-Conrad