I am using Ruby on Rails 3.0.9 and jQuery 1.6.2. I would like to “render an action file” from a folder not in the current view file used\displayed.
In my articles_controller file I have:
respond_to do |format|
format.html {
# ...
}
format.js {
render :action => 'shared/article.js.erb' # Note the 'shared' folder
}
end
Making an AJAX HTTP request from the article view (the view is the show.html.erb file and it is located in views/articles folder) I get the following error:
ActionView::MissingTemplate (Missing template articles/article with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:js, :html], :locale=>[:en, :en]}...
How can I solve that?
The log file is the following:
Started GET "/articles/2/article" for 127.0.0.1 at 2011-07-24 13:05:16 +0200
Processing by ArticlesController#article as JS
ActionView::MissingTemplate (Missing template ActionView::MissingTemplate (Missing template articles/article with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:js, :html], :locale=>[:en, :en]}...
On Rails 3, this should work:
If it does not, you can be explicit:
More about this on the rendering chapter at Rails Guides.