Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Contact < ActiveRecord::Base
- ...
- end
- map.resources :contacts
- class ContactsController < ApplicationController
- ...
- def show
- @contact = Contact.find(params[:id]
- respond_to do |format|
- format.html
- format.xml {render :xml => @contact}
- format.js {render :json => @contact.json}
- end
- end
- ...
- end
- /contacts/1 # Responds with regular html page
- /contacts/1.xml # Responds with xml output of Contact.find(1) and its attributes
- /contacts/1.js # Responds with json output of Contact.find(1) and its attributes
Add Comment
Please, Sign In to add comment