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 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 |
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 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 |
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 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 |
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 | |
| has_many :posts, | |
| inverse_of: :user | |
| attr_accessible :name, :email | |
| 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 Post < ActiveRecord::Base | |
| belongs_to :user, | |
| inverse_of: :posts | |
| attr_accessible :body, :title | |
| 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 | |
| has_many :posts, | |
| foreign_key: 'author_id', | |
| inverse_of: :author | |
| attr_accessible :name, :email | |
| 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 Post < ActiveRecord::Base | |
| belongs_to :author, | |
| class_name: 'User', | |
| foreign_key: 'author_id', | |
| inverse_of: :posts | |
| attr_accessible :body, :title | |
| 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
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.strategy = Capybara.current_driver == :rack_test ? :transaction : :truncation | |
| DatabaseCleaner.clean | |
| DatabaseCleaner.start | |
| 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
| module Seeders | |
| module Lessons | |
| class << self | |
| def seed | |
| Lesson.destroy_all | |
| lessons = [] | |
| base_path = 'db/seed_data' | |
| Dir.glob(Rails.root.join(base_path, 'lessons', '*.yml')) do |file| | |
| lesson = YAML.load_file(file) |
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 IntervalWorker | |
| def initialize(interval_id) | |
| @interval_id = interval_id | |
| end | |
| def perform | |
| interval = Interval.where(id: @interval_id).first | |
| interval.complete! if interval.present? | |
| end | |
| end |