some basic api functionality with a few gotchas
This commit is contained in:
@@ -5,9 +5,17 @@ class Api::V1::UsersController < ApplicationController
|
|||||||
before_filter :extrapolate_user
|
before_filter :extrapolate_user
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ class User < ActiveRecord::Base
|
|||||||
def full_name
|
def full_name
|
||||||
"#{self.first_name} #{self.last_name}"
|
"#{self.first_name} #{self.last_name}"
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user