Hello, fellow TA. We're really glad to have you on the Rails 5 update team!
Our students are already using Rails 5, but our curriculum is not. We're going to fix that.
We'll be updating the curriculum to Rails 5.1.2.
Before going on, I recommend you check that you have that specific version installed.
Run rails -v
.
If you're not up-to-date, run the following: gem install rails --version=5.1.2
.
In this document, I'll go over how to update our curriculum's web applications (i.e. projects, homework, assessments) and readings.
In updating the curriculum, all pull requests will be checked for the following:
Rails 5 brings a few brand-new technologies along with it.
But the update we're making in-and-of-itself won't add any utilization of these technologies to our curriculum.
In the future, we could add some readings on ActionCable
, ActiveJob
, and/or api_mode
, but let's leave those for the future.
It might even be possible to integrate some of these technologies into our projects at a later date.
As always, make sure that your updates don't introduce bugs. If your designated project updates happen to come with specs, use them. Whether or not your projects come with specs, manually test every bit of functionality!
What students read in the instructions should align with their experiences.
Let me give you an example of this not being the case.
One project currently mentions that a blank controller action without a corresponding view should raise a Missing template
error.
While that is the case in Rails 4, the default response in such a situation in Rails 5 is instead head :no_content
.
This was a source of confusion for the majority of students, and it also took the TA's a while to pinpoint this new behavior.
Let's avoid this.
For projects, please read and compare all responses and logs with any that are mentioned in the instructions.
For readings and quizzes, please ensure that all of the code blocks and quotations accurately reflect how Rails 5 actually behaves.
This update is a massive overhaul, and we want to get it through quickly. The longer we take to merge this update, the more time we'll spend merging in concurrent updates to the curriculum. To avoid treading water, we'll aim to move quickly. We should be able to finish this before the next SF cohort begins using Rails (August 17, 2017).
Please keep this in mind when working on your assignments!
The update-rails branch will be the primary branch for this update. However, each update assignment will likely be quite large. For this reason, you should branch off of update-rails for your assignments.
To make the tracking of everyone's progress easier, all sub-branch names should be prefixed with update-rails
.
For instance, if you happen to be assigned to update the readings and homework of w4d4, create a new branch titled update-rails-w4d4
.
If you happen to be assigned the updating of a project, say Movie Buff, you should create a new branch called update-rails-movie-buff
.
Once you finish up your work, please make a pull request where update-rails is the base and your branch is the compare.
Please avoid merge conflicts with other peoples' updates.
What follows is a description of what I've experienced updating our projects and readings.
Replace the Rails entry with this:
gem 'rails', '~> 5.1.2'
Then, run:
bundle update rails
Run the following:
rails app:update
There are some changes to schema.rb
.
Unique indexes are now in the create_table
methods.
Run the following:
rails db:migrate
Rake tasks are now runnable via rails
.
Please replace rake
with rails
.
Before Rails 5.x, all models inherited directly from ActiveRecord::Base
.
In Rails 5, all models inherit from ApplicationRecord
.
This means that you need to create a new file in your /models
folder by the name of application_record.rb
:
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
In Rails 5, all belongs_to
relations are required and validated.
If you happen to come across a belongs_to
relationship that should be optional, please add optional: true
and ensure that the corresponding instructions explain this behavior.
In Rails 5, has_many_through
relations must come after the has_many
or belongs_to
relations that they utilize.
This seems like an unlikely issue with the current curriculum, but keep an eye out.
For controller tests, be sure to wrap action request parameters in params
.
For instance:
get :show, id: 1
should become this:
get :show, params: { id: 1 }
Ensure that all of the things mentioned in the above section are represented, when relevant, in the readings.
If you happen to find typos or explanations that could be improved, feel free to change them. This is a good opportunity to make our curriculum is easier to read.
When updating quizzes, please ensure that any referenced logs/responses are exactly what Rails 5 produces.
Rake tasks are now runnable via rails
.
Please replace rake
with rails
.