Class: Visitor
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Visitor
- Defined in:
- app/models/visitor.rb
Overview
Schema Information
Table name: visitors
id :integer not null, primary key
email :string(255) default(""), not null
encrypted_password :string(255) default(""), not null
reset_password_token :string(255)
reset_password_sent_at :datetime
remember_created_at :datetime
sign_in_count :integer default(0)
current_sign_in_at :datetime
last_sign_in_at :datetime
current_sign_in_ip :string(255)
last_sign_in_ip :string(255)
created_at :datetime not null
updated_at :datetime not null
first_name :string(255)
last_name :string(255)
provider :string(255)
uid :string(255)
agb :boolean default(FALSE)
newsletter :boolean
confirmation_token :string(255)
confirmed_at :datetime
confirmation_sent_at :datetime
unconfirmed_email :string(255)
failed_attempts :integer
unlock_token :string(255)
locked_at :datetime
authentication_token :string(255)
username :string(255)
loginable_type :string(255)
loginable_id :integer
Class Method Summary collapse
- .find_for_facebook_oauth(auth, signed_in_resource = nil) ⇒ Object
-
.new_with_session(params, session) ⇒ Object
if you want to allow your users to cancel sign up with Facebook, you can redirect them to “cancel_user_registration_path”.
Instance Method Summary collapse
Class Method Details
.find_for_facebook_oauth(auth, signed_in_resource = nil) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/models/visitor.rb', line 84 def self.find_for_facebook_oauth(auth, signed_in_resource=nil) #logger.error auth.inspect visitor = Visitor.where(provider: auth.provider, uid: auth.uid).first unless visitor visitor = Visitor.find_by_email(auth.info.email) if visitor.present? visitor.provider = auth.provider visitor.uid = auth.uid visitor.save else pass = Devise.friendly_token[0,20] visitor = Visitor.create(username: auth.info.name, provider: auth.provider , uid: auth.uid , email: auth.info.email , password: pass , password_confirmation: pass, agb: true ) end end visitor end |
.new_with_session(params, session) ⇒ Object
if you want to allow your users to cancel sign up with Facebook, you can redirect them to “cancel_user_registration_path”
109 110 111 112 113 114 115 |
# File 'app/models/visitor.rb', line 109 def self.new_with_session(params, session) super.tap do |user| if data = session["devise.user_data"] && session["devise.user_data"]["extra"]["raw_info"] user.email = data["email"] if user.email.blank? end end end |
Instance Method Details
#send_confirmation_mail ⇒ Object
78 79 80 81 82 |
# File 'app/models/visitor.rb', line 78 def send_confirmation_mail if self.email.present? && Goldencobra::Setting.for_key('visitors.send_confirmation_mail') == 'true' Goldencobra::ConfirmationMailer.send_confirmation_mail(self.email).deliver! end end |
#title ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'app/models/visitor.rb', line 68 def title if self.username.present? self.username elsif self.first_name.present? && self.last_name.present? "#{self.first_name} #{self.last_name[0]}." else self.email end end |