some basic api functionality with a few gotchas

This commit is contained in:
cktricky
2014-03-12 17:45:08 -04:00
parent ed800fd601
commit 48ddc99955
2 changed files with 17 additions and 2 deletions
+10 -2
View File
@@ -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
+7
View File
@@ -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