Skip to content

Commit

Permalink
Rails 5 updates for job board curriculum
Browse files Browse the repository at this point in the history
* quiet_assets is no longer needed (though we contrivedly
  talk about `bundle install` anyway)
* Different (worse?) errors for missing templates
* ApplicationRecord instead of active record
* Migrations have this version thing
* `null: false` is missing from timestamps in migrations
  • Loading branch information
tjgrathwell committed Jul 9, 2016
1 parent e05a717 commit 9cc2b13
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions sites/en/job-board/create_a_rails_app.step
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ MARKDOWN

discussion_box "Text Editor vs Command Line", "Review the differences between the the command line and your text editor, even if everyone already knows!"

message "# Fix Up Those Defaults"
message "# Let's Talk About Dependencies"

source_code_with_message "We're going to be looking at the Rails server output, which includes a lot of noise by default. Find the file called 'Gemfile' by searching for it, and add the following line:", :ruby, "gem 'quiet_assets'"
message "When we created a new Rails app, it installed a bunch of stuff by default. The list of things Rails installed is in a file called `Gemfile`. If you want to add any additional third party code (aka **gems**), you can add more lines to the `Gemfile` and install them with `bundle`."

console_with_message "Save the file, and then in the command line, run the following command:", "bundle install"
console_with_message "Rails has already installed all the stuff we need, but you can always run bundle again to re-install gems, or install gems newly added to the Gemfile. In the command line, run the following command:", "bundle install"

discussion_box "What does 'bundle' do?", <<-MARKDOWN
Bundler is the tool the Ruby community uses for dependency management.
Expand Down
2 changes: 1 addition & 1 deletion sites/en/job-board/job-board.step
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ message <<-MARKDOWN
We're also going to skip deploying to Heroku this time around, but you can definitely use the instructions from the Suggestotron curriculum to deploy your app to the internet!
MARKDOWN

important "This curriculum is written for Rails 4. Things will get awkward / broken if you're using Rails 3, so if you skipped the Installfest, you need to upgrade to Rails 4 now."
important "This curriculum is written for Rails 5. Things will get awkward / broken if you're using an earlier version of Rails, so if you skipped the Installfest, you need to upgrade to Rails 5 now."

message <<-MARKDOWN
# Tips for everyone:
Expand Down
2 changes: 1 addition & 1 deletion sites/en/job-board/listing_the_jobs.step
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MARKDOWN

message "# Show those jobs!"

source_code_with_message "Add this to app/views/jobs/index.html.erb:", :ruby,
source_code_with_message "Add this to app/views/jobs/index.html.erb:", :erb,
<<-RUBY
<% @jobs.each do |job| %>
<h3><%= job.title %></h3>
Expand Down
8 changes: 3 additions & 5 deletions sites/en/job-board/make_a_jobs_home_page.step
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ MARKDOWN
source_code_with_message "We're going to need a resource route, which will create EIGHT different routes for us. Add this to line two:", :ruby, "resources :jobs"

message <<-MARKDOWN
Now, lets go look at what that made, by using the excellently helpful page available on any Rails 4 app: <http://localhost:3000/rails/info>.
Now, lets go look at what that made, by using the excellently helpful routes page: <http://localhost:3000/rails/info>.
MARKDOWN

discussion_box "How to read the routes page.", <<-MARKDOWN
Expand All @@ -49,8 +49,6 @@ discussion_box "How to read the routes page.", <<-MARKDOWN
Can you find the line that will make `/jobs` a route?
MARKDOWN

tip "If you are on Rails 3, going to /rails/info will **fail**! Stop right now and upgrade to Rails 4."

message <<-MARKDOWN
Since adding the line `resources :jobs` made a route matching `/jobs`, let's go visit that page again: <http://localhost:3000/jobs>
MARKDOWN
Expand Down Expand Up @@ -97,10 +95,10 @@ RUBY

message "And refresh <http://localhost:3000/jobs>"

error_box "Missing template jobs/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in: * '/Users/probablyyou/railsbridge/job_board/app/views'"
error_box "JobsController#index is missing a template for this request format and variant."

message <<-MARKDOWN
What's the important part of the this error? How does Rails decide to look for something called jobs/index? How did it decide to look in the views directory?
What's a template? How does Rails decide to look for the template associated with JobsController's `index` action?

Talk through what Rails is trying, and failing, to do, and how file names and method names are important here.

Expand Down
6 changes: 3 additions & 3 deletions sites/en/job-board/make_the_form_work.step
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ source_code :ruby,
end
RUBY

message "Reload the page!"
message "Try to use your form again. Unfortunately, there won't be any output, not even an error page. But if you look closely at the output from your Rails server, you might find this:"

error_box "Missing template jobs/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in: * '/Users/lillie/railsbridge/job_board/app/views'"
error_box "No template found for JobsController#create, rendering head :no_content"

<<-MARKDOWN
Familiar error, right? We don't have a template called create.html.erb.
Expand Down Expand Up @@ -78,7 +78,7 @@ source_code :http,
JSON

message <<-MARKDOWN
This is the precious data that our form is sending, and right now we're just throwing it away. Let's not do that! Since we're using Rails 4 and all its great conventions, we're going to use Strong Parameters to limit what kind of data our form can submit to our app.
This is the precious data that our form is sending, and right now we're just throwing it away. Let's not do that! Since we're using Rails 5 and all its great conventions, we're going to use Strong Parameters to limit what kind of data our form can submit to our app.
MARKDOWN

source_code_with_message "Add this code to your jobs controller. (Notice that we're expanding the create method. Don't just copy and paste and end up with two create methods, folks.)", :ruby,
Expand Down
6 changes: 3 additions & 3 deletions sites/en/job-board/store_jobs_in_the_database.step
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ message <<-MARKDOWN
MARKDOWN

source_code :ruby, <<-RUBY
class CreateJobs < ActiveRecord::Migration
class CreateJobs < ActiveRecord::Migration[5.0]
def change
create_table :jobs do |t|

t.timestamps null: false
t.timestamps
end
end
end
Expand All @@ -55,7 +55,7 @@ source_code :ruby, <<-RUBY
create_table :jobs do |t|
t.text :title
t.text :description
t.timestamps null: false
t.timestamps
end
RUBY

Expand Down
2 changes: 2 additions & 0 deletions sites/en/job-board/update_job_listings.step
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ source_code_with_message "Say we want to edit the first job posting. If we look

message "So, it looks like if we want to edit the job description, we should visit this URL: <http://localhost:3000/jobs/1/edit>."

error_box "The action 'edit' could not be found for JobsController"

source_code_with_message "We've seen this before, right? Let's add the controller action:",
<<-RUBY
def edit
Expand Down

0 comments on commit 9cc2b13

Please sign in to comment.