Skip to content

Instantly share code, notes, and snippets.

@lengarvey
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lengarvey/fb0ec0718e6ac4a7e362 to your computer and use it in GitHub Desktop.
Save lengarvey/fb0ec0718e6ac4a7e362 to your computer and use it in GitHub Desktop.
Rails Girls Next - Guided Rails tutorial

Rails Girls Next

We're going to go through learning some more Ruby on Rails. I've based this guide on the Installfest guides that I built when I was working for Reinteractive. The goal is to take a blog application (that we can build from scratch by following the Installfest guide) and make a series of changes to the blog so that we can learn some stuff as we go.

Goals

  1. Learn the foundations of testing.
  2. Improve our knowledge of HTTP/HTML and CSS.
  3. Build a thing that you can deploy on the internet.
  4. Have some fun?

Specifically we'll learn about:

  1. Testing Rails applications and TDD.
  2. Markdown and creating a simple Ruby thing to do Markdown.
  3. Learning about how to change a database using migrations.
  4. Creating static pages in Rails
  5. Customising Error pages in Rails. See http://www.lego.com/sdfsdfsdfsdf for an example of a not found page.

Prerequisites

  1. Ruby is installed and working. We'll help you check that.
  2. You know what text-editor you're using. We can help you with that too.
  3. Some knowledge of the terminal. We can guide you with this too

Setup

  1. Download: https://github.com/lengarvey/rails_girls_next_blog/archive/v1.0.zip
  2. Unzip that file.
  3. Open the quick_blog directory in your terminal and type bundle install --without-production
  4. Run rake db:setup
  5. Run rails server
  6. Open http://localhost:3000 in your browser of choice.

If that produces a nicish looking blog page you're all set to go.

The guide

Open https://gist.github.com/lengarvey/ca6086da02e74cdd65a4 and head to the "Setup" heading.

Rails Girls Next

Testing is a fundamental part of becoming a developer, and something that can seem confusing. Roughly speaking we write tests for two reasons:

  1. We want to make sure that something doesn't break. Regression testing
  2. We know what we want, but don't know how to make it yet. Test Driven Development, or TDD

Regression tests

Imagine that someone reports a bug in your program. They can't log into the website. If you can write an automated test that has the same error, when you fix this error your test will also pass. When you run this test in the future you can have more confidence that the user won't experience the same bug again.

Test Driven Development

Your client asks you to implement an admin panel in the blogging system. You don't know how to do this yet. But we can write a test that describes the feature. This way we start to understand the feature, and get an idea on how we might implement it. When the test passes we know that we've finished writing our feature too. As a bonus we've got increased confidence that the feature won't break in the future, provided we keep running our tests regularly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment