Respond With

Examples Usages
Responding with JSON
Responding with XML
Responding with Text
Responding to All
Last updated

Last updated
class PetController < ApplicationController
def index
pets = Pet.all
respond_with { json pets.to_json }
end
endclass PetController < ApplicationController
def index
pets = Pet.all
respond_with do
xml render("index.xml.slang", layout: false)
end
end
endclass PetController < ApplicationController
def index
pets = Pet.all
respond_with{ text "hello world" }
end
end
endclass PetController < ApplicationController
def index
pets = Pet.all
respond_with do
html render("index.slang")
json pets.to_json
xml render("index.xml.slang", layout: false)
text "hello world"
end
end
end