1respond_to do |format|
2 format.json { render :json => @user, :except=> [:ip] } # or without format block: @user.to_json(:except => :ip)
3end
4
1class User < ActiveRecord::Base
2 def to_json(options={})
3 options[:except] ||= [:ip]
4 super(options)
5 end
6end
7
1class User < ApplicationRecord
2 def as_json(options={})
3 options[:except] ||= [:ip]
4 super(options)
5 end
6end
7