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
| ((UP "CREATE TABLE IF NOT EXISTS edge (in_vertex INTEGER,out_vertex INTEGER)") | |
| (DOWN "DROP TABLE IF EXISTS edge")) |
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
| ((UP ,(lambda (db) (do-something-nifty-with db))) | |
| (DOWN ,(lambda (db) (undo-something-nifty-with db)))) |
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
| ((UP "CREATE TABLE vertices (id INTEGER, name STRING)") | |
| (DOWN (#f . "You must not remove vertices") )) |
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
| (use nomads nomads-sql-de-lite fmt fmt-color filepath) | |
| (migration-directory "./migrations") | |
| (database-credentials "test.db") | |
| (define (get-version) | |
| (let ((version (get-environment-variable "VERSION"))) | |
| (if version | |
| (or (string->number version) (string->symbol version)) | |
| 'latest))) |
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 Base < ActiveRecord::Base | |
| self.abstract_class = true | |
| end | |
| # the table foobars has the column abort:string | |
| class Foobar < Base | |
| self.table_name = "foobars" | |
| 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 MissmatchRecorder | |
| attr_reader :record | |
| def initialize | |
| @record = "" | |
| end | |
| def <<(msg) | |
| @record << msg | |
| 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
| your_map = @users.inject({}) do |m,u| | |
| duplicates = @users.select{ |u2| u.id != u2.id && u.email == u2.email } | |
| (m[u.email] ||= []).concat(duplicates) unless duplicates.empty? | |
| m | |
| 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 Company < ActiveRecord::Base | |
| attr_accessible :name | |
| has_many :parent_associations, :class_name => 'Association', :foreign_key => 'child_id' | |
| has_many :child_associations, :class_name => 'Association', :foreign_key => 'parent_id' | |
| has_many :parents, :through => :parent_associations, :source => :parent | |
| has_many :children, :through => :child_associations, :source => :child | |
| 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
| Object.send(:alias_method,:_m,:method) | |
| class Foo | |
| def reverse(thing) | |
| thing.reverse | |
| end | |
| def map_reverse(things) | |
| things.map(&_m(:reverse)) | |
| 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 User < ActiveRecord::Base | |
| validates :phone_number, presence: true, length: { is: 11 }, if: :gsm_number_empty?, unless: :password_or_email_changed? | |
| validates :gsm_number, presence: true, length: { is: 11 }, if: :phone_number_empty?, unless: :password_or_email_changed? | |
| private | |
| def password_or_email_changed? | |
| encrypted_password_changed? || email_changed? | |
| end | |
| def phone_number_empty? | |
| !phone_number.present? |
OlderNewer