Skip to content
Dave Strus edited this page Nov 13, 2014 · 2 revisions

Solution

app/models/note.rb

class Note < ActiveRecord::Base
  belongs_to :user
end

app/models/user.rb

class User < ActiveRecord::Base
  has_secure_password
  has_many :notes
  validates :password, length: { :minimum => 8 }
end
bin/rails g migration create_notes
class CreateNotes < ActiveRecord::Migration
  def change
    create_table :notes do |t|
      t.string :title
      t.text :body_html
      t.text :body_text
      t.references :user, index: true
      t.timestamps
    end
  end
end
bin/rake db:migrate

Commit.

$ git add .
$ git commit -m "Add Note model"