Skip to content

Commit

Permalink
Add users_controller and set as show/index resource in routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtko committed Mar 16, 2013
1 parent 0f35eb4 commit e6d30a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class UsersController < ApplicationController
before_filter :authenticate_user!
before_filter :set_as_current_user_if_me, :only => :show
load_and_authorize_resource

def index
respond_to do |format|
format.json { render :json => @users }
end
end

def show
respond_to do |format|
format.json { render :json => @user }
end
end

private
def set_as_current_user_if_me
@user = current_user if params[:id] = 'me'
end
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
resources :attachments
end

resources :users, :only => [:index, :show]

get "/active_users" => "apis#active_users"
get "/me" => "apis#me"

Expand Down

0 comments on commit e6d30a4

Please sign in to comment.