Skip to content

Commit

Permalink
Moving to_json parameters over to the model so that they're used when…
Browse files Browse the repository at this point in the history
…ever a User is json'd
  • Loading branch information
Tom Copeland committed Oct 17, 2009
1 parent 5e5e521 commit de6439b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Expand Up @@ -2,7 +2,7 @@ class UsersController < ApplicationController

def show
respond_to do |wants|
wants.js {render :json => user.to_json(:except => [:unix_pw, :email, :user_pw, :confirm_hash]) }
wants.js {render :json => user }
end
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Expand Up @@ -117,6 +117,10 @@ def password
def home_directory
"/home/#{user_name}"
end

def to_json(args = {})
ActiveSupport::JSON.encode(as_json({:except => [:unix_pw, :email, :user_pw, :confirm_hash]}.merge(args)))
end

end

0 comments on commit de6439b

Please sign in to comment.