This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def avatar_url(user) | |
| gravatar_id = Digest::MD5::hexdigest(user.email).downcase | |
| if user.image | |
| user.image | |
| else | |
| return "https://www.gravatar.com/avatar/#{gravatar_id}.jpg?d=identicon&s=50" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.find_for_google_oauth2(access_token, signed_in_resourse=nil) | |
| data = access_token.info | |
| user = User.where(:provider => access_token.provider, :uid => access_token.uid).first | |
| if user | |
| return user | |
| else | |
| registered_user = User.where(:email => access_token.email).first | |
| if registered_user | |
| return registered_user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Client < ActiveRecord::Base | |
| belongs_to :user | |
| has_many :call_center_touches | |
| has_many :support_touches | |
| has_many :sales_touches | |
| has_many :client_events | |
| has_many :events, through: :client_events | |
| def self.text_search(query) | |
| self.where("similarity(name, ?) > 0.2 OR similarity(iin, ?) > 0.2 OR similarity(email, ?) > 0.2 OR similarity(phone, ?) > 0.2" , query, query, query, query).order("similarity(name, #{ActiveRecord::Base.connection.quote(query)}) DESC") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AddAttachmentImageToPhotos < ActiveRecord::Migration | |
| def self.up | |
| change_table :photos do |t| | |
| t.attachment :image | |
| end | |
| end | |
| def self.down | |
| remove_attachment :photos, :image | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PostgreSQL. Versions 9.1 and up are supported. | |
| # | |
| # Install the pg driver: | |
| # gem install pg | |
| # On OS X with Homebrew: | |
| # gem install pg -- --with-pg-config=/usr/local/bin/pg_config | |
| # On OS X with MacPorts: | |
| # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
| # On Windows: | |
| # gem install pg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PostgreSQL. Versions 9.1 and up are supported. | |
| # | |
| # Install the pg driver: | |
| # gem install pg | |
| # On OS X with Homebrew: | |
| # gem install pg -- --with-pg-config=/usr/local/bin/pg_config | |
| # On OS X with MacPorts: | |
| # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
| # On Windows: | |
| # gem install pg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PostgreSQL. Versions 9.1 and up are supported. | |
| # | |
| # Install the pg driver: | |
| # gem install pg | |
| # On OS X with Homebrew: | |
| # gem install pg -- --with-pg-config=/usr/local/bin/pg_config | |
| # On OS X with MacPorts: | |
| # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
| # On Windows: | |
| # gem install pg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
| def facebook | |
| # You need to implement the method below in your model (e.g. app/models/user.rb) | |
| @user = User.from_omniauth(request.env["omniauth.auth"]) | |
| if @user.persisted? | |
| sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated | |
| set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format? | |
| else | |
| session["devise.facebook_data"] = request.env["omniauth.auth"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ApplicationRecord | |
| # Include default devise modules. Others available are: | |
| # :confirmable, :lockable, :timeoutable and :omniauthable | |
| devise :database_authenticatable, :registerable, | |
| :recoverable, :rememberable, :trackable, :validatable, | |
| :confirmable, :omniauthable | |
| validates :fullname, presence: true, length: {maximum: 50} | |
| def self.from_omniauth(auth) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| var platformLanguage = navigator && ( | |
| navigator.language || | |
| navigator.browserLanguage || | |
| navigator.systemLanguage || | |
| navigator.userLanguage || | |
| null ), | |
| elemsRU, elemsUK, elemsKZ, elemsEN; | |
| if (platformLanguage.match("ru") && document.getElementsByClassName) { | |
| elemsRU = document.getElementsByClassName("b-text_lang_ru"); |