Getting Started with Ruby on Rails

Foundations for Building Web Apps with Ruby on Rails
4.2 (103 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
9,401 students enrolled
$19
$20
5% off
Take This Course
  • Lectures 47
  • Length 16 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 6/2012 English

Course Description

This course covers all you need to get started with building Web applications with Ruby on Rails. It takes you from basic material on the best practices that are embedded into the Rails framework, through to advanced material on developing real time applications with Rails.

The course contains screen casts and practical examples. We show you how to get coding right away using Nitrous - a cloud based development environment. So there is no need to spend time on the tedious business of installing tools on your own machine.

I am not a full-time teacher. My courses are informed by extensive real-world application development both in industry and academia. So I teach you what works in practice, and by following this course you will benefit from my 35 years' experience in a wide range of software engineering projects.

What are the requirements?

  • Some experience in computer programming
  • Ideally some experience in Object Orientation

What am I going to get from this course?

  • Basics of Ruby
  • The MVC architecture of Rails
  • How Rails supports the Development of Models
  • How Rails supports the Development of Views
  • Best Practice in the use of HTML5 and CSS3
  • Best Practice in Behavioural Driven Development
  • How to use an extensive range of Ruby Gems to maximise productivity
  • CSS3 Animations
  • Responsive Design

What is the target audience?

  • Those with a wish to gain a broad foundation in the technology and processes needed for developing Web Applications with Ruby on Rails.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Basic Introduction to Ruby for Rails Developers
27:57

This lecture introduces the goals of the course, and then moves on to some Ruby basics, followed by a picture of the Rails framework. It's a fairly light-weight lecture so let it all wash over you and get ready for a bit more work next time.

17:08

Installing Ruby on Rails on your own machine can be a real pain point. I strongly recommend using the Nitrous.io development environment "in the cloud". It all works smoothly and enables you to get straight into learning Ruby and Rails. This lecture shows you how to get started with Nitrous.

06:11

The Nitrous Desktop is now available for both Windows and Mac. It enables you to synchronise files between Nitrous and your local machine. This means you can (a) keep a local copy of your Nitrous project, and (b) edit the project with an editor on your own machine and have it synchronise with the project in Nitrous. At the end of the lecture I introduce the Interactive Ruby Console (IRb) that will be used in the next few lectures on Ruby.

30:48
This lecture covers some basics of Ruby, focussing on some of the features that are particularly exploited in Rails. It also introduces Classes in Ruby.
14:34
This lecture looks at how to read and access class instances in Ruby, how to control access to Ruby's methods and how to declare subclasses of a given class. It also contains a short but important homily on the difference between a variable and the internal representation of an object that is referenced by a variable.
20:22

Now you have some familiarity with Ruby, it is worth getting to know the IRb (Interactive Ruby) tool a little better to enable you to explore the language. This lecture contains some worked examples of using the IRb to introduce the basic commands and some of the cool things you can do if you want to experiment with Ruby.

8 pages

This handout contains an extended coding example in Ruby in order to provide a little more detail about some aspects of the language. It also contains a few simple exercises to test your understanding. Answers to these will be available in the supplementary material section.

Section 2: Handling Static Pages in Rails
30:51

Now we can start to take a look at Rails. In this lecture, I will provide a quick reminder of the details of the MVC architecture, show some basics of using embedded Ruby to generate content for View files and finally use Rails' generated links to navigate between pages.

An archive of the complete project that was created for this lecture can be found in the supplementary material. I do strongly recommend taking the trouble to type up the code for the project by hand first, but you may find the archive useful to refer to if you have any problems.

18:10

This lecture introduces the larger sample application that we will use for the remainder of the course. We will explore rails routes a little more, and then introduce the layout file that fleshes view files out into complete html documents. Finally, we will introduce helpers, that can be used to customise view files.

13:52

In this lecture, we will introduce the use of Rails' "partials" to capture small reusable chunks of html content. Specifically, we will use partials to capture the header, footer and nav bar for our website.

We will also take another look at our routes, and introduce the Rails "link_to" method.

Section 3: Getting Your Processes Sorted
13:26

Process is important. It is particularly important when you are working with a team. But even if you are working on your own, using the techniques and tools that I will introduce you to in this chapter will protect you from a number of potential disaster scenarios, and help to ensure that you deliver a quality product to your customer.

This opening lecture provides a short overview of the material that will be covered in the rest of this chapter.

13:04

There are two broad choices for a Rails development environment. Many prefer the lightweight command line plus programmer's editor route. The alternative is to use a full fledged IDE. I will talk about both in this lecture.

I will also briefly cover the options for backend database.

27:34
Another best practice that is supported by Ruby and Rails is Behaviour Driven Development. This lecture introduces two BDD tools, Cucumber and RSpec. Cucumber supports the creation of feature level scenarios. RSpec is more usually used for specifying behaviours of smaller chunks of code. Both levels of specification can be executed against the code base and so are essential tools for supporting iterative specification/development/test cycles.
28:24

Having developed well specified and tested code, you will now want to maintain it in a carefully managed repository,won't you! In this lecture we will review the fundamentals behind the distributed version control system Git, and show you how to set up a remote repository in GitHub.

16:02
The final part of this chapter covers the use of Heroku to deploy stable increments of your project "into the Cloud". This enables you to close the feedback loop with your customer and is a key part of the process. We will also take a quick review of what we have learnt in this chapter.
Section 4: Now Add Some Database Magic
20:37

We will replace the static Events page with a dynamically generated index of Events in this lecture. This will introduce you to Rails' Active Record. This manages the Object-Relational mapping that takes care of the relationship between a Rails model at its persistent representation in the database. We will use a scaffold generator to produce the: events controller; all the views that correspond to actions in the controller; an update to the routes.rb file; the database migration; and, of course, the Event.rb class for the model itself.

23:16

We have generated a model with a CRUD interface so that users may add and update events. But we also need to ensure that all the data that must be provided before an event is saved, is indeed provided - and in the correct format. For that we use Rails Validations. Even more importantly, we need to ensure that only authorised users change data. We introduce Ruby's Action Callbacks and then use these to place an authentication layer on those actions whose access needs to be controlled. Rather than code up authentication from scratch, we will use the Devise gem. This will also introduce you to the use of Ruby Gems.

12:25

Building Associations between classes is so easy in Rails. This lecture demonstrates how we can use Active Record to build a one-to-many association between two classes in a model. We also show how to ensure that dependent objects are destroyed automatically when a parent object is destroyed.

17:07

Rails has some impressive support for Model Building in Active Record. The key thing about this is that (a) Rails uses conventions to free you from the routine configuration of your model implementation, and (b) you are now free to think deeply about your domain model. In this lecture we will say a little more about the association types that are supported by Active Record, but more importantly, start to show you how to think deeply about your models. Be very clear about this. No matter how good you are at developing Rails apps, there will always be someone who is better. But your Model is going to remain your unique selling point - you have to get it right!

32:06

We left the sample application with a couple of issues. Firstly, the foreign key for the event that is associated with a comment needed to be added manually. In this lecture we will see how to automatically pass the foreign key to the comments controller. Secondly, the comments are on a different page to the associated event. We will move the comments for a specific event to that event's Show page. Finally, we will use some jQuery magic to hide and reveal the comments list without page refresh. This will provide an introduction to the use of jQuery and unobtrusive JavaScript.

You will find a zip file containing the complete code for the project so far under the Resources section. This should have all the links correctly setup as per the discussions around this lecture, but do send me a message if I have missed anything.

Section 5: A Touch of Style
32:44

As we build up content in this Chapter, we will also start to style our sample web application. Before we commit to styling we need to pull together a Boilerplate of best practice to handle cross-browser compatibilities and other known issues to ensure our application has a consistent look and feel.

23:09

We will gain more experience of using the new HTML5 elements in this lecture. They will help us provide meaningful structure to the pages in our application. In addition, we will start to bring in some basic styling with CSS.

35:49

CSS can do magic, but it also does a lot of things badly.

Sassy CSS sorts out the issues properly and makes CSS truly DRY. We will first introduce Sprockets - a general purpose tool for managing asset pipelines. Then we will show how SCSS enables you to define and structure your styling assets much more effectively than was possible with vanilla CSS.

Section 6: Take a REST
31:34

In keeping with its maxim of "Convention over configuration", Rails includes support for designing/generating "RESTful" APIs. In this chapter, we will review the basics of routing in Rails, and then discuss how the concepts of REST (Representational State Transfer) are used in Rails.

30:54

This lecture looks in detail at the mappings from Routes to Controller Actions that are automatically generated for you when you declare a Resource in Rails. As well as simplifying the navigation through your application, it also automatically generates a public facing RESTful API for you. We will show how to make this API respond to requests for different representations of a resource.

Section 7: And a Sprinkling of Gems
07:42

Ruby Gems enable you to extend Rails Core with best practice solutions for many of the common programming problems that are found when building Rails Apps. These are easy to plug into your project and offer mature and stable enhancements. We will explore some of the best in more detail in the remainder of the lectures in this chapter.

22:34

Active Admin is a rich and powerful Gem for generating the back end Administration functionality for a Rails Web Application. It includes Devise for authentication, and use Formtastic to generate the forms it uses. It is highly recommended, and extensively used by the Rails community to provide the Administration components of web applications.

N.B. Some of you have seen a clash between the earlier installation of Devise and Active Admin. As a result, you may find it easier/safer to start this lecture with a clean build of the sample application that has not got Devise installed. The archive file that is available here as a download should provide a good starting point. Once you have unzipped the file, you will need to cd into its root directory, bundle install and migrate the database to the current version. Then check it runs okay. Once that is done, you can install Active Admin as per this lecture. Note that once you have installed Active Admin, you will need to add the authentication filters in as per Lecture 14 - this includes adding in the sidebar that is described in Slide 17 of that lecture. (Note also that the before_filter you need to use is: authenticate_user!.

20:50

These two gems offer complementary functionality. CarrierWave supports upload of media files into a Web Application. RMagick provides some extremely useful image processing capability. We will see how these two gems can work together to enable us to add the capability to upload image files, and have them automatically resized into versions that are suitable for different uses in our Sample Application.

Section 8: Now What Have We Got
08:24

I give a quick summary of where we are, and then provide some pointers to sources of material for continuing the adventure.

If you are ready to take a more intensive web development course, Bloc offers a Developer Apprenticeship. You can save $100 on enrollment with the coupon code "learnrails".

How Bloc Works:

  • Continuous coaching: Meet 3 times per week, one-on-one, with a Bloc mentor vested in your success.
  • Intensive: Bloc is a results-focused program with a 25 hour/week commitment.
  • Real-World projects: You'll build clones of Reddit, Wikipedia, Kissmetrics, and Google Reader and learn industry standard tools.
  • Jump-start your passion project: As your final capstone project, you'll build your own Ruby on Rails website from scratch with your mentor's help.
Section 9: Starting the Move to the Next Level
37:16

This lecture covers more detail about Git. While much of the focus is on the use of Git's capability for using branches, a number of other important features are introduced. Once you have gone through this lecture you should have enough information to both work on your own projects and contribute to a shared project.

41:20

We show off ActiveRecord::Live with a simple application for streaming data from the server into a client view. We start off with the simplest of examples but gradually refine this into a comprehensive end-to-end example that captures all the key technology you need to stream data into a Rails View. There is a lot of new stuff in this lecture: JavaScript; jQuery; Server-Sent Events. I will introduce these, but we will go into them all in more depth as we progress through the advanced material.

Section 10: Appendix: HTML5 Basics
13:45
As a bonus for all those taking this course, I have included all the material in my "HTML: Ready, Set, Go" course as an appendix.
In this first lecture, we answer the question of what is HTML. This naturally leads into a short discussion on why it is important to take a standards-based approach to using HTML. Finally, the lecture provides a short overview of the content of the remainder of this Appendix.
14:24
In a sense, HTML as we know it today was not "built by design". Instead, it has evolved over the last twenty years through a collective learning experience from standards bodies, browser developers and users. The very high level history of HTML in this lecture focuses on some key milestones that helped to define HTML as it is today.
07:47
This short lecture introduces the key elements that are needed in a valid HTML document.
11:56
The HTML Document Object Model (DOM) support an alternative representation in which HTML elements in a document are represented as objects. The DOM API then enables properties of the elements to be changed, and even for elements to be added to, or removed from, the tree of objects. Consequently the DOM plays important roles in the styling of HTML (using CSS) and the dynamic update of content (using JavaScript). 
21:07
Given that the textual content is barely visible in a browser, it is important to understand that the <head> element is a critically important part of your HTML document. Apart from the Docytpe declaration, it is the first part of your document that a user agent sees, and so sets expectations for the remainder of your document. It is also where references to the stylesheets and script files that are used in your HTML document belong.
24:50
The latest HTML5 specification identifies a number of categories of elements. However, the basic distinction between block type and inline elements is still very useful for understanding the overriding purpose of the different elements. They work at very different levels of granularity: block type elements provide structure to an html document; inline elements mark up small sections of content in a block that need to be distinguished in some way.
15:16

The two key lessons of this lecture are:

  1. Follow the HTML5 recommendation of declaring your document as using the UTF-8 Unicode encoding scheme;
  2. Once you have done that, eliminate (as far as is possible) character references.
You will also find the Unicode Character Code Charts to be a useful reference:

http://www.unicode.org/charts/

23:12
We are now in a position to start marking up the text in a document. HTML5's new semantic elements provide us with more flexibility and more precision in structuring our documents. We first show how restrictive life was with HTML4, and then use a simple example to demonstrate the effectiveness of the new semantic elements.
12:42
Tables got a bit of a bad name as they were often misused for laying out web pages. Don't ever do that!!! However, tables are a valuable tool for presenting large amounts of data. This lecture will introduce you to how to use HTML to provide a clean semantics to the elements in a table.
21:35
The use of forms is pervasive on the interactive Web. I will introduce HTML forms and demonstrate best practice in marking up a form to fully describe its structure. This is especially important in order to support accessibility. 
19:05
Links are the stuff of the Web. Given their importance, the syntax for a link is mercifully simple (and rightly so). Nevertheless, there are some good practices to take note of, and some bad practices to steer clear of.
12:12
All the work in the last three chapters has been helping you to produce valid HTML5 documents. But there is still the chance of errors arising. These will not necessarily be picked up by browsers, as they are designed to be error tolerant. This is a key difference between parsing HTML and parsing XML. In the case of the former, a browser will try to second guess what you intended if it finds an error. In the latter case, the browser will simply stop the parsing and return a failure condition if it finds an error. But you should still try to flush out any errors as they will manifest themselves sooner or later in a hard to diagnose failure. This lecture shows you how to use the W3C validator - do it, it does not take long!
19:38
The Web is all about access to all, and HTML5 provides strong support in this direction. Nevertheless there are still a number of additional techniques that can be used to enhance the accessibility of your site. We will discuss some of them in this lecture, but be aware that this is the start of a journey that will continue through the exploration of CSS and Dynamic HTML.
16:05
Now we are at the end of the course, let's just sit back with a reflection on the overall messages of the course. You can also see some pointers as to what to work on next.
Section 11: Appendix: CSS3 Design Patterns
16:47
We will use the "Image Replacement" design pattern to illustrate the basic approach. It is built up from two low-level design patterns: Background Image; and, Absolute. As a result, you will learn more good practice than just copying one design pattern - these two low-level design patterns give you some generally applicable good practice. That is why I argue that working with design patterns is such an effective way of learning CSS; you get to do interesting things, but also get to learn the basics at the same time. 
22:00
A horizontal tab bar is almost ubiquitous in modern web sites. However, it can be a little tricky to set up in CSS. This design pattern will give you a rock solid way of doing it. Along the way, you will meet the Outside-in Box design pattern, which is a cool way of managing the CSS Box Model.

Once you have the basic Tab Pattern mastered, you can try giving it a little more impact with the use of the CSS3 Transition animation. This just shows you how you can get some really impressive visual effects but without using JavaScript or Flash.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Paul Krause, Professor of Software Engineering, University of Surrey

Paul Krause is Professor of Software Engineering at the University of Surrey. Prior to moving to his full-time Professorship in 2003, he was a Senior Principle Scientist at Philips Electronics. During his time at Philips he consulted widely with their global software development teams in Bruges, Eindhoven, Vienna, Bangalore and Singapore. He also wrote and delivered training courses on a wide range of advanced software development techniques both to individual teams and at the Global Philips Software Conference.

Since moving to the University of Surrey, his teaching has focused on Web Technologies. He teaches at both Undergraduate and Postgraduate level, with his courses always receiving very strong scores in the student feedback. He uses many of the technologies he teaches in his research work, ensuring that his taught material is both up to date and full of practical insights. During the last 13 years he has delivered introductory, intermediate and advanced level courses on: Java, Ruby on Rails, JavaScript (including Node.js, jQuery and Angular.js) and Behaviour Driven Development.

Prof. Krause was one of the authors of the first versions of the British Computer Society’s Information System Examination Board’s Foundation and Practioner’s Software Testing syllabuses. He is Editor (Computing and Software) of the Institute of Engineering and Technology’s Journal of Engineering, and a Guest Mentor at Coding House, CA.

He has travelled widely in Europe, Africa and Asia both for pleasure and for work. This has given him a broader perspective than just the technical aspects of his work, and this is also reflected in some of his Udemy courses.

Ready to start learning?
Take This Course