Skip to content

Commit de6439b

Browse files
author
Tom Copeland
committed
Moving to_json parameters over to the model so that they're used whenever a User is json'd
1 parent 5e5e521 commit de6439b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: app/controllers/users_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class UsersController < ApplicationController
22

33
def show
44
respond_to do |wants|
5-
wants.js {render :json => user.to_json(:except => [:unix_pw, :email, :user_pw, :confirm_hash]) }
5+
wants.js {render :json => user }
66
end
77
end
88

Diff for: app/models/user.rb

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def password
117117
def home_directory
118118
"/home/#{user_name}"
119119
end
120+
121+
def to_json(args = {})
122+
ActiveSupport::JSON.encode(as_json({:except => [:unix_pw, :email, :user_pw, :confirm_hash]}.merge(args)))
123+
end
120124

121125
end
122126

0 commit comments

Comments
 (0)