INTRODUCTION - Learn Ruby on Rails For Web Development (2015)

Learn Ruby on Rails For Web Development (2015)

INTRODUCTION

"Rails? What a bloated waste of time...I'll NEVER use it for anything...ever."

That was really the first thought I had about Rails when I first looked into using it almost a decade ago. I'm an old school PHP guy who always built websites by simply punching out HTML and PHP onto Windows Notepad by hand, saving the file and uploading it to my regular apache web server using basic FTP software.

Compared to that, Rails seemed like a massive and unnecessary sort of thing. Who needs a whole big framework just to build a simple website?

And talk about complicated! The first time I tried to install Rails, I gave up in complete frustration after about an hour and a half.

Compared to hand-coding some HTML and PHP on notepad and then FTP'ing it up to my server, this Rails thing seemed borderline insane! In fact, it wasn't till recently that I even bothered to check out Rails again, and I'm glad I did because once you get past the insanity that is Rails installation...Rails is a dream to use!

It's just...fun!

You can do so much with Rails, so quickly, that it makes anything else seem crazy by comparison...even basic PHP.

It's true, there's a bit of a learning curve...in fact, it's unnecessarily hard to get started using Rails in the beginning unless you have someone to guide you through it (that's where this book comes into play). But once you get past a few initial rough patches, Rails is really quite easy...and I've been there so I can ease you through those initial bumps along the way.

In fact, I think you'll be surprised just how quickly you'll be building apps...

SO WHAT EXACTLY IS RUBY ON RAILS?

Ruby on Rails is an open source web development framework written in the Ruby programming language that makes creating apps and websites incredibly easy.

It uses something called a model/view/controller architecture that does a lot of the dirty work of dealing with databases and things like that for you, allowing you to focus on what's important to develop your app with speed and ease.

It was created by David Heinemeier Hansson back around 2004 - 2005 ish and quickly became one of the most popular app frameworks in the world. Many popular sites use it, including Groupon, Indiegogo, Airbnb, Yammer, SoundCloud, Scribd, Shopify, Hulu and many many others. Twitter was initially developed using Rails. Yep.

WHO IS THIS BOOK FOR?

This book is for the absolute Rails beginner. You don't need to have any prior experience with Rails whatsoever. It'll be helpful if you have some web development experience of some sort (a basic understanding of HTML is a plus, Javascript is a plus too) but you certainly don't need to know anything at all to get started with this book.

I'll walk you through absolutely everything you need to know step by step.

DO YOU NEED TO LEARN THE RUBY PROGRAMMING LANGUAGE?

The first thing that most people tend to ask me is whether or not you need to learn the Ruby programming language to use Rails. Though it is called Ruby on Rails, you don't really need to know Ruby to start using Rails to develop web apps.

We'll be using some simple embedded Ruby along the way (embedded Ruby is just Ruby that's used on a web page...embedded on a web page), but it'll be very basic Ruby and I'll walk you through it.

If you have any experience with other programming languages, you'll be able to pick up Ruby pretty easily. There are lots of free resources online that will teach you the basics. In fact, I'm finishing up a book on basic Ruby at the moment that you can check out if you're interested in learning more.

WHAT WILL WE MAKE IN THIS BOOK?

No one wants to read boring dry instructions. That's a fairly terrible way to learn anything! Instead we'll spend most of this book actually building an app from start to finish.

In this case, we'll be building a clone of Pinterest. Why Pinterest? Lots of reasons, really. Pinterest is one of the most popular websites on the Internet, it'll allow us cover a broad range of topics that you'll be able to use forever in whatever app/website that you work on in the future. It'll teach us how to create users, log them in and out of our app, allow them to upload text and images to a database, and then stylize all that stuff onto a webpage using some neat effects.

Plus, I think you'll discover that building Pinterest is pretty easy! Hopefully that realization will give you the confidence to strike out and build your own cool stuff. If a site like Pinterest is this easy to create, well, you can probably build just about anything!

HOW DO YOU LEARN?

Some people learn best by reading, others learn by watching or listening...still others learn by using their hands and actually do-ing things. It's my goal to tick as many of those boxes as possible to give you the tools you need to really learn Rails quickly and easily in whatever method of learning works best for you.

So in addition to this book, I've also created an online video course that follows along with the book. You can actually watch me complete each of the steps in the book and build our clone of Pinterest right in front of your eyes.

You can ask me questions online if you get stuck along the way, hang out with everyone else who's enrolled in the course on the course message board, and copy and paste all the code snippets from this book.

The video course is hosted at the online code school, Codemy.com and you can follow along and watch at your own pace.

We've got a lot of different courses besides this rails course. If you're interested in learning Internet Marketing, Web Development, or how to build an online Startup I highly recommend you check Codemy.com out. People are actually raving about it, which is pretty cool!

Full Membership gets you access to all the courses for just $497, or you can sign up for individual video courses (like this Rails course) for just $97 each.

As a thank you for reading this book, I'd like to offer you $22 off the Rails course. Just use coupon code amazon when you order from:

http://www.Codemy.com/rails/

CONVENTIONS USED THROUGHOUT THE BOOK

This is a book about computer programming, so the layout is a little bit different than your average work of fiction (or non-fiction for that matter).

First let's talk terminology.

I won't use a lot of weird technical terms...and if I do I'll be sure to explain them.

One thing I want to mention is my use of the term 'app'. Most people use the phrase 'app' when talking about anything made online these days, and especially anything created using Rails.

I tend to use the phrase 'website' instead of 'app'. I guess technically a website is just an App...and Rails will build an 'App' directory...but what can I say...I'm weird I guess. To me a website is a website...so I tend to call them websites.

So just sort of be aware that I'll generally slip between the phrase 'app' and 'website' interchangeably when I get excited. You should probably emulate the cool kidz and just call them apps.

I'll be writing a lot of code in this book, and I'll usually designate that code by displaying it in big grey boxes as per the regular convention to list code in big grey boxes. That should make it easier to read and less jumbled with the rest of the text of the book.

Unfortunately, Kindle books don't generally show those big grey boxes, the formatting they use tends to strip that sort of thing out. In that case, hopefully the code will show up in a numbered list. Each number represents a line of code, sort of like this:



1 <% if user_logged_in? do %>
2 something here
3 <% else %>
4 Do something else
5 <% end %>

Everyone who signs up for my Ruby on Rails course over at Codemy.com will get a pdf version of this book for free, and that pdf has code listed with the traditional grey boxes which I think makes everything easier to differentiate.

Finally, we'll be using something called the "command line", sometimes called the "terminal" extensively throughout this book (and in everyday Rails life).

If you aren't familiar with the command line, don't worry, I'll explain it in a moment. But for now, just understand that when I write command line commands, I'll also be writing them in the same sort of big grey boxes that I display code in.

Normally a rails app will be deep in a unix-style directory, like this:

/home/ubuntu/workspace/your_rails_app/

And the command line convention is to put the name of your computer/user before that directory structure. So your command line might look something like this:

Elder-laptop: /home/ubuntu/workspace/your_rails_app/ $

That dollar sign "$" is the command prompt.

I'm not going to type all that stuff out every time I tell you to type a command line command. Instead I'll generally just write the dollar sign and the command, and you should assume that command should be typed into the directory where you Rails app is sitting. So it might look something like this:



$ rake db:migrate

Which means; in the directory /home/ubuntu/workspace/your_rails_app/ type the rake db:migrate command.

But like the grey box problem I just mentioned a second ago with our code snippets, Kindle is going to strip out the grey box for my command line examples, so I'll also use the numbered method like the code snippets, like so:



1 $ rake db:migrate
2


Cool?

Cool.