You need to create two models using the generator. They look like this. After performing the migration and transition to the rails console, we must successfully execute the following commands :
project = Project.create title: "Мой проект" todo = Todo.create text: "Обсудить проект с женой" project.todos << todo Problem: I get RollBack on the second team and nothing happens
Class Code:
class Project < ApplicationRecord has_many :todos end class Todo < ApplicationRecord belongs_to :project end Migration code:
class CreateProjects < ActiveRecord::Migration[5.0] def change create_table :projects do |t| t.string :title t.timestamps end end end class CreateTodos < ActiveRecord::Migration[5.0] def change create_table :todos do |t| t.string :text t.boolean :isCompleted t.references :project, foreign_key: true t.timestamps end end end Which teams can generate models to make it work? Help me find errors, thanks!
CreateTodosmigration (if you have applied it) and replaceisCompletedwithis_completed. - D-side