create_a_rails_app.step

goals do
  goal "Make a new Rails app"
  goal "Add a few gems to make life easier"
  goal "Learn a little about Bundler and dependency management"
  goal "Start the Rails server and see the default Rails page"
  goal "commit early, commit often"
end


steps do

  step "create a rails app" do


  console "rails new job_board -T -d postgresql --minimal"

  message <<-MARKDOWN
    * The `-T` in that command means that when you make new files using Rails generators, it doesn't automatically create files for automatic testing
    * The `-d` in that command is for choosing the database.
    * The `--minimal` disables a dozend advanced features of rails that we won't need today

    Watch all the files that are created! Wow!
  MARKDOWN
  end


  step "open the code in your editor" do
    console_with_message "Move into the directory for your new Rails app:", "cd job_board"

    console_with_message "Start VS Code from the commandline:", "code ."

    message <<-MARKDOWN
      Or do it the other way round: open VS code first, and then open the folder

      * Open VS Code
      * Under File, "Open Folder"

    MARKDOWN
  end

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

  step "Create The Database" do

  message "When we created a new Rails app,  we specified postgresql as the database. Do you have a postgres server running locally?"

  console_with_message "To create the databases we need run the following command:", "rails db:create"

  end


  step "Look at the Dependencies" do

  message "When we created a new Rails app, it installed a bunch of packages 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 **gem**), you can add more lines to the `Gemfile` and install them with `bundle`."

  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.

  * 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

  end


  step "start the development server" do

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

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

  end

  step "open the app in the browser" do
  message <<-MARKDOWN
    Now, let's check out our default home page

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

    Yup, that's the default Rails home page - even if your version numbers are a bit higher, and
    you are running on a different computer.
  MARKDOWN

  message "<img src='img/successful_rails7_install.png' srcset='img/successful_rails7_install.png 1x, img/successful_rails7_install@2x.png 2x'>"

  end
end

commitnow do
  message "commit this initial state of the code to git"
end

next_step "the_request_cycle"