Skip to content

Instantly share code, notes, and snippets.

@SET001
Last active December 11, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SET001/4662209 to your computer and use it in GitHub Desktop.
Save SET001/4662209 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable
# :registerable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :first_name, :last_name, :country, :city, :address, :phone, :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
has_many :users_roles
has_many :roles, :through => :users_roles
def as_json(options = nil)
res = {}
[:first_name, :last_name, :country, :city, :address, :phone, :email, :last_sign_in_at].each do |el, index|
res[el] = self[el]
end
res
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment