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