Table name: users
id :integer not null, primary key
name :string(255)
email :string(255) not null
crypted_password :string(255)
salt :string(255)
activation_state :string(255)
activation_token :string(255)
activation_token_expires_at :datetime
reset_password_token :string(255)
reset_password_token_expires_at :datetime
reset_password_email_sent_at :datetime
remember_me_token :string(255)
remember_me_token_expires_at :datetime
created_at :datetime
updated_at :datetime
type :string(255)
admin :boolean default(FALSE)
uuid :string(255) default("")
availability_defaults :text
response_time :text
searchable :boolean default(FALSE)
last_name :string(255)
phone :string(255)
credits :integer default(0)
balanced_customer_uri :string(255)
credits_booked :integer default(0)
points :integer default(0)
streak :integer default(0)
level :integer default(1)
exp_title :string(255)
minimum_level :integer default(1)
balanced_api_id :text
is_featured :boolean default(FALSE)
is_registration_completed :boolean default(FALSE)
is_manually_deactivated :boolean default(FALSE)
billing_address_1 :string(255)
billing_address_2 :string(255)
billing_city :string(255)
billing_state :string(255)
billing_zipcode :string(255)
shipping_address_1 :string(255)
shipping_address_2 :string(255)
shipping_city :string(255)
shipping_state :string(255)
shipping_zipcode :string(255)
location :string(255)
experience :string(255)
summary :text
awards :string(255)
skills :string(255)
industry :string(255)
profile_step :integer
headline :string(255)
onboard_step :integer
pending_chat_with :integer
cached_notification_count :integer default(0)
cached_message_count :integer default(0)
auth_token :string(255)
company_id :integer
level_changed :boolean
skills_count :integer default(0)
subtrades_count :integer default(0)
rate_in_cents :integer default(2000)
To check if any subrade is exists for the customer.
# File app/models/customer.rb, line 126 def added_subtrades? subtrades.exists? end
Find confirmed session
# File app/models/customer.rb, line 86 def confirmed_sessions ExpertSession.where("user_id = ? and end_time <= ? and status = 'c'", self.id , Time.now.in_time_zone) end
To check if customer has credit
# File app/models/customer.rb, line 111 def has_credits? remaining_credits > 0 end
To find if customer has a expert session
# File app/models/customer.rb, line 101 def has_expert_sessions? expert_sessions.exists? end
to find if customer is part of any groups
# File app/models/customer.rb, line 96 def has_groups? groups.exists? end
To check whether customer profile is completed
# File app/models/customer.rb, line 121 def profile_completed? !customer_incomplete? end
To find remaining credits
# File app/models/customer.rb, line 116 def remaining_credits (credits - credits_booked) > 0 ? (credits - credits_booked) : 0 end
To find if Customer has sent invitations
# File app/models/customer.rb, line 106 def sent_invites? invites.exists? end
To find upcoming expert sessions
# File app/models/customer.rb, line 91 def upcoming_expert_sessions ExpertSession.where("user_id = ? and end_time > ? and (status is null or status != 'r')", self.id , Time.now.in_time_zone) end