diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index a23daf3..d995abb 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -5,9 +5,17 @@ class Api::V1::UsersController < ApplicationController before_filter :extrapolate_user respond_to :json - + def index - respond_with @user + # We removed the .as_json code from the model, just seemed like extra work. + # dunno, maybe useful at a later time? + #respond_with @user.admin ? User.all.as_json : @user.as_json + + respond_with @user.admin ? User.all : @user + end + + def show + respond_with @user.as_json end private diff --git a/app/models/user.rb b/app/models/user.rb index 2af7dc2..7705a10 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -37,6 +37,13 @@ class User < ActiveRecord::Base def full_name "#{self.first_name} #{self.last_name}" end + +=begin + # Instead of the entire user object being returned, we can use this to filter. + def as_json + super(only: [:user_id, :email, :first_name, :last_name]) + end +=end private