Created
January 13, 2011 16:45
-
-
Save pramatias/778151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/routes.rb | |
ActionController::Routing::Routes.draw do |map| | |
map.resources :chatters do |chatter| | |
chatter.resources :chats | |
end | |
#app/controllers/chats_controller.rb | |
#Parameters: {"chat"=>{"id"=>"1", "message"=>"cool"}} | |
class ChatsController < ApplicationController | |
# GET /chats | |
# GET /chats.xml | |
def find_by_id | |
logger.info "The params Id is #{params['chat']['id']}" | |
@chats = Chat.find(:first, :conditions => {:id => params["chat"]["id"] }) | |
respond_to do |format| | |
#format.html # index.html.erb | |
format.xml { render :xml => @chats.id } | |
end | |
end | |
#app/controllers/chatters_controller.rb | |
#Parameters: {"chatter"=>{"name"=>"second_chatter"}} | |
class ChattersController < ApplicationController | |
# GET /chatters | |
# GET /chatters.xml | |
def find_by_name | |
logger.info "The params Id is #{params['chatter']['name']}" | |
@chatters = Chatter.find(:first, :conditions => {:name => params["chatter"]["name"] }) | |
respond_to do |format| | |
#format.html # index.html.erb | |
format.xml { render :xml => @chatters.id } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment