Skip to content

Instantly share code, notes, and snippets.

class CreateCats < ActiveRecord::Migration
def change
create_table :cats do |t|
t.string :color
t.integer :crazy_cat_lady_id, null: false
t.timestamps
end
end
end
@mikeraimondi
mikeraimondi / validation_example_1.rb
Created June 9, 2013 15:30
association validation example
class CrazyCatLady < ActiveRecord::Base
has_many :cats,
inverse_of: :crazy_cat_lady
end
class Cat < ActiveRecord::Base
belongs_to :crazy_cat_lady,
inverse_of: :cats
validates_presence_of :crazy_cat_lady
@mikeraimondi
mikeraimondi / boolean_default_example.rb
Created June 5, 2013 03:12
boolean default example
class CreateWidgets < ActiveRecord::Migration
def change
create_table :widgets do |t|
t.string :name, null: false
t.string :description
t.boolean :flanged, default: false
t.timestamps
end
end
@mikeraimondi
mikeraimondi / null_constraint_example.rb
Created June 5, 2013 03:08
null constraint example
class CreateWidgets < ActiveRecord::Migration
def change
create_table :widgets do |t|
t.string :name, null: false
t.string :description
t.timestamps
end
end
end
class CrazyCatLady < ActiveRecord::Base
has_many :cats,
inverse_of: :crazy_cat_lady
end
class Cat < ActiveRecord::Base
belongs_to :crazy_cat_lady,
inverse_of: :cats
end
@mikeraimondi
mikeraimondi / gist:5625024
Created May 22, 2013 03:18
Rails has_many association
class CrazyCatLady < ActiveRecord::Base
has_many :cats
end
class Cat < ActiveRecord::Base
belongs_to :crazy_cat_lady
end
  • As a visitor, I want to understand what the site is offering so I can quickly orient myself
    • I should see a tagline on the main page
    • I should see a brief summary on the main page
  • As a visitor, I want to sign up so I can save my progress and receive updates
    • I should see a sign up link on the index
    • I should see a form that allows me to sign up
    • I should be required to provide a unique user name or email
    • I should be required to provide a strong password
    • I should be required to confirm my password
  • I should be signed in after completing the form
def query_question_answers
question_answers = []
i = 1
begin
puts "Please enter a question"
question = gets.chomp
puts "Please enter the answer"
answer = gets.chomp
question_answers.push([question,answer])
if i >= 2
QUESTION_ANSWERS_DEFAULT = [
['What is your name?','Arthur'],
['What is your quest?', 'The Holy Grail'],
['What is the airspeed velocity of an unladen swallow?', 'African or European?']
]
FILE_PATH = 'question_answer.txt'
def load_question_answers(file)
lines = []
[mike:~/GDrive/rails_projects/atsalarm] master ± cd ~
[mike:~] $ clear
[mike:~] $ mkdir Documents/challenge_app
[mike:~] $ cd Do
Documents/ Downloads/ dotfiles/ dotfiles_old/
[mike:~] $ cd Documents/challenge_app/
[mike:~/Documents/challenge_app] $ git init
Initialized empty Git repository in /Users/mike/Documents/challenge_app/.git/
[mike:~/Documents/challenge_app] $ rails new challenge_1
create