Creating ActiveRecord Models
Learn how to add new migrations and models, and how to make the end-to-end test pass.
We'll cover the following...
We can see the first error by running the test:
rsync -avr --progress /usercode/* /usr/local/educative/gatherer --exclude Gemfile --exclude Gemfile.lock --exclude execute_.sh --exclude execute.sh cd /usr/local/educative/gatherer clear bundle exec rspec
The add_project_spec.rb file of our Rails app
Since Project
isn’t yet a standard ActiveRecord resource with routes, the test (unsurprisingly) can’t find new_project_path
.
ActiveRecord models
If we read the previous chapter and wondered when we would create ActiveRecord models, our time has come. We need to save to the database for the end-to-end test to pass. We’ll use the Rails resource
generator, which creates a controller, migration, and route, but doesn’t put any code in the generated controller.
Note: This creates a bunch of files that we’re unlikely to use, but we’ll let that part slide for now. ...