In Controllers => api => V1
create "users_controllers.rb"
the code inside this controller may seems something like following
class Api::V1::HotelsController < ApplicationController
def show
@user = user.find( params[:id] )
respond_to do |format|
format.json {render :json => @user}
format.xml {render :xml => @user}
end
end
end
_____
Now go to routes and Add the following
namespace :api do
namespace :v1 do
resources :users
end
end
____________
now run $ rake routes | grep users
and check the path against the show method. this will seem something like following.
"/api/v1/users/:id"
---
Now hit http://localhost:3000/api/v1/users/(any ID like 1,2 or 3).json
No comments:
Post a Comment