Skip to content

Instantly share code, notes, and snippets.

@AlexJWayne
Created September 16, 2009 02:46
Show Gist options
  • Select an option

  • Save AlexJWayne/187832 to your computer and use it in GitHub Desktop.

Select an option

Save AlexJWayne/187832 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>hal9000.say { render :js => 'Hello Dave.' }</title>
<%= javascript_include_tag :defaults %>
</head>
<body>
<fieldset>
<legend>This is where the test happens</legend>
<%= yield %>
</fieldset>
</body>
</html>
class FoobarController < ApplicationController
def index
end
def hello_world_text
render :text => "alert('Hello World with :text')"
end
def hello_world_js
render :js => "alert('Hello World with :js')"
end
end
<p>
<%= link_to_remote 'Ajax with :js', :url => get_my_js_path, :update => 'output' %>
</p>
<p>
<%= link_to_remote 'Ajax with :text', :url => get_my_text_path, :update => 'output' %>
</p>
<div id="output"></div>
ActionController::Routing::Routes.draw do |map|
map.foobar '/foobar', :controller => 'foobar'
map.get_my_text '/foobar/text', :controller => 'foobar', :action => 'hello_world_text'
map.get_my_js '/foobar/js', :controller => 'foobar', :action => 'hello_world_js'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment