Answers for "rails hide field in json"

0

rails hide field in json

class User < ApplicationRecord
  def as_json(options={})
    options[:except] ||= [:ip]
    super(options)
  end
end
Posted by: Guest on June-01-2021
0

rails hide field in json

respond_to do |format|
  format.json { render :json => @user, :except=> [:ip] } # or without format block: @user.to_json(:except => :ip)
end
Posted by: Guest on June-01-2021
0

rails hide field in json

class User < ActiveRecord::Base
  def to_json(options={})
    options[:except] ||= [:ip]
    super(options)
  end
end
Posted by: Guest on June-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language