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 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
| 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
| 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
| 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
| devise_for :users, :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout', :edit => 'profile'}, | |
| :controllers => {:omniauth_callbacks => "omniauth_callbacks", registrations: 'users/registrations'} |
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
| if ARGV.include? "Titanic" | |
| puts "Titanic is a bad movie" | |
| elsif ARGV.include? "Matrix" | |
| puts "Matrix is a good movie" | |
| else | |
| puts "Haven't seen #{ARGV} yet" | |
| 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
| good_movies = [ 'Matrix', 'GOT', 'Hobbit', 'LOTR', 'Batman' ] | |
| bad_movies = [ 'Titanic', 'Terminator', 'Cloverfield', 'Vikings', 'WD' ] | |
| bad_answer = bad_movies & ARGV | |
| bad_answer.each { |ba| puts "#{ba} is a bad movie"} | |
| good_answer = good_movies & ARGV | |
| good_answer.each { |ga| puts "#{ga} is a good movie"} |
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
| if ARGV.length != 1 | |
| puts "We need exactly one parameter. The name of a file." | |
| exit; | |
| end | |
| filename = ARGV[0] | |
| puts "Going to open '#{filename}'" | |
| fh = open filename |