Skip to content

Instantly share code, notes, and snippets.

@rks
Created July 14, 2011 15:19
Show Gist options
  • Save rks/1082651 to your computer and use it in GitHub Desktop.
Save rks/1082651 to your computer and use it in GitHub Desktop.
class ThingsController < ApplicationController
respond_to :html, :json
before_filter { @thing = {one: 1, two: 2} }
# /things/a -> renders template at things/a.html.erb
# /things/a.json -> renders @thing.to_json
def a
respond_with @thing
end
# /things/b -> renders the template at b.html.erb
def b
do_some_stuff_with @thing
do_some_other_stuff
end
private
def do_some_stuff_with(something)
something[:three] = 3
end
def do_some_other_stuff
# whatever...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment