create_a_rails_app.step

message <<-MARKDOWN
  # What we're going to do:

  * Make a new Rails app
  * Add a few gems to make life easier
  * Start the Rails server and see the default Rails page
  * Learn a little about Bundler and dependency management

  # Get Set Up

  First, let's get into a directory for RailsBridge projects (either by finding your existing one & moving there or making a new folder).

  If you don't already have a RailsBridge folder, use the commands `mkdir` and `cd` to create one and move into it:
MARKDOWN

console_without_message "mkdir railsbridge"
console_without_message "cd railsbridge"

message <<-MARKDOWN
  # Rails New!!!
MARKDOWN

console "rails new job_board -T"

message <<-MARKDOWN
  The `-T` in that command means that when you make new files using Rails generators, it doesn't automatically create test files using Test::Unit (the default Rails testing framework).

  Watch all the files that are created! Wow!

  # Open the project in Sublime Text
MARKDOWN

console_with_message "Move into the directory for your new Rails app:", "cd job_board"

message <<-MARKDOWN
  And open the project in Sublime:

  * Open Sublime
  * Under Project, choose "Add Folder to Project"

  (You must have at least one window open, so if that option is greyed out, open a window with cmd+n (Mac) or ctl+n (PC))
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"

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'"

source_code_with_message "And delete the following line:", :ruby, "gem 'turbolinks'"

console_with_message "Save the file, and then 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.

 * What's dependency management?
 * Why do we need it?
 * Why do we even need gems?
 * Is there a shorter method to use for `bundle install`? (Hint: yes!)
MARKDOWN

message <<-MARKDOWN
# Really clear out TurboLinks

Turbolinks is a Rails thing that we don't want. We got rid of part of it above, but let's finish the job.
MARKDOWN

source_code_with_message "Within app/assets/javascripts, open up application.js and delete this line:", :ruby, "//= require turbolinks"

source_code_with_message "Within app/views/layouts, open up application.html.erb and delete the following from lines five AND six: ", :ruby, "'data-turbolinks-track' => true"

message "Lines five and six should end up looking like this: "

source_code :erb, <<-ERB
  <%= stylesheet_link_tag    "application", media: "all" %>
  <%= javascript_include_tag "application" %>
ERB

message "# Look at your empty app"


tip "Now is a good time to figure out how to have multiple tabs or windows of your terminal or command prompt. Starting and stopping the Rails server all day is tedious, so it's good to have one terminal tab or window for running commands, and a separate one for the server."

console_with_message "Start the Rails server by running this command in the terminal:", "rails server"

message <<-MARKDOWN
  Now, let's check out our default home page

  In the broswer, visit <http://localhost:3000>

  Yup, that's the default Rails home page!
MARKDOWN

next_step "the_request_cycle"