I've renamed my .rhtml files to .html.erb and everything works fine. Renaming .rjs to .js.rjs; however, does not. Pages don't render unless I specifically tell them to using render :template. Any thoughts? Is the .js.rjs naming convention not quite ready yet? Thanks, Norman
on 08.05.2008 16:48
on 09.05.2008 05:06
Yes, js.rjs works just fine in Rails 2.0.2.
You must be missing something. I did a simple useless test to just
hide a div using RJS. Here how it looks:
routes.rb:
map.resources :offers, :collection => { :hide => :get }
offers_controller:
def hide
respond_to do |format|
format.js
end
end
hide.js.rjs:
page.hide "hide_me"
index.html.erb:
<p><%= link_to_remote "Hide Me", :url => { :action => 'hide' } %></p>
<div id="hide_me">
Some stuff to hide
</div>
application.html.erb:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Hello World</title>
<%= javascript_include_tag :defaults %>
</head>
<body>
<%= yield %>
</body>
</html>
on 09.05.2008 19:04
Yes, you need the "respond_to do |format|" specified in your controller. Prior to 2.0, rjs files worked without this. Now they don't, as far as I can tell. -Kyle