In this core Ruby on Rails 2.0 course, you are going to actually build and deploy a web application written in Ruby on Rails, learning how to use Ruby on Rails along the way.
When we’re wrapped up on the final day, everybody will have a working web application we'll have built
ourselves during this course - and live on the Internet. We will keep it live for a couple of weeks, so that you can show it off to your friends and enhance it. At the end of the course, you’ll have the complete source code you wrote, plus the sample solution of this Ruby on Rails course.
DAY 1: BELIEVE THE MAGIC
Today is just a whirlwind tour of what Rails can do. You’re not going to be expected to understand what’s going on, just believe in the magic for now.
Get Rails installed
- Check the skeleton application into subversion.
- Introduction to Subversion
- why version control is so important
- What the rails command actually does.
- A tour of the files it generates
- Setting up a database.
- The differences between environments.
- What’s new in Rails 2.0.
- Tracking Rails in our own source tree instead of relying on the version installed on the system.
Pull in a few essential plugins required for development
- RSpec for test-driven development
- Test driven development versus behaviour-driven development - It’s all about expressing and validating your intentions
- A nicer form builder - yet_another_form_builder.
- exception_notification to receive an email of errors in production.
- Customising Rails - a few of the plugins you can use to change Rails’ default behaviour to something you prefer, including namespaced_nested_resources
Creating a resource called "Book", our main book object-
Generators and what they do
- Taking a look at what’s generated
- Basic introduction to routing. Stick with “believe the magic” mantra for now.
- Models, views & controllers, their roles and where to find them
- Database migrations
- A discussion on how to model books
An initial deployment
- Creating yet another plugin, which makes the deployment magically easy
- What happens when you do cap deploy.
- Rolling back mistakes
By the end of Day 1, you will have a fully working, deployed, Ruby on Rails application available on the Internet (so you can show friends and family that night), which will allow
you to list books and enter data. You will be encouraged to go tinker with the
application that evening if you can.
DAY 2: UNDERSTANDING THE MAGIC: MODELS
Today we’re going to concentrate on building and enhancing the models in the application. That’s not to say we won’t be incidentally covering controllers & views of a resource at the same time, but models are what we’ll focus on.
Enhancing the book model to include validations
- Seeing the various types of validation that are built in
- How we can create our own custom validation.
- Implementing the validation for the Book model, including validating the correctness of an ISBN.
- Introduction to idiomatic Ruby coding too.
- Seeing how the validations propagate up to the user interface
Model categories/genres
- Introduction to has_many and belongs_to.
- Introduction to the author model as a separate entity
- How to model the relationship (has_and_belongs_to_many or has_many :through).
In each case, we’ll attempt to write the model bits in a test-driven manner. We will first discuss what we want from an implementation, then you'll be writing your own set of tests to exercise the implementation we’ve discussed. Then we will look at this course's sample set of tests, just so everybody is on the same page for the actual implementation. You will then go ahead and implement whatever we have agreed during our discussions. You will run your own tests, to see that it’s working and once everyone is reasonably happy with their
implementation, we’ll review these with the class.
DAY 3: UNDERSTANDING THE MAGIC: CONTROLLERS
Today, we’ll take a deeper look at controllers
- Basic layout of a resourceful controller, including CRUD and REST
- The routing system in more depth
- Enhancing a controller, with extra actions that don’t map well into the CRUD architecture.
- Filters and implementing authentication for our application
DAY 4: UNDERSTANDING THE MAGIC: VIEWS
Finally, we’ll cover the views in depth.
- Idiomatic use of HTML ids, classes and the use of dom_id (directly or indirectly) to refer to a particular model’s data in the view.
- Partials and layouts
- Enhancing the views with a bit of AJAX. Here you will learn why we’ve left the
whizz-bang UI stuff to the last day: so that we have a fully functioning application which will degrade well in the absence of JS support and built with accessibility in mind
- Optimising the application’s views for mobile devices. We’re going to build an iPhone-optimised version of the site at the tail end of the day
When we’re wrapped up on the Friday, you will have a working web application you will have built yourself - and live on the Internet! We will keep it live for a couple of weeks, so that you can show it off to anyone who likes to see it, and so you can further practice by enhancing it.
Upon completion of this Ruby on Rails course, you will have the complete source code you wrote,plus this Ruby on Rails course's sample solution