Ruby On Rails Overview

John Elder
A free video tutorial from John Elder
Founder of Codemy
4.4 instructor rating • 57 courses • 136,847 students

Lecture description

In this video we'll create a new Ruby on Rails project and I'll explain the default directory structure of Rails. The Rails directory structure can seem overwhelming, but it's actually very simple to understand; as I'll show you in this video.

Learn more from the full course

Ruby On Rails: Stock Market App

Build a Cool Stock Quote App In Rails

09:24:12 of on-demand video • Updated July 2020

  • Build Web Apps With Ruby On Rails
  • Build Your Own Stock Market Website
  • Understand the Bootstrap CSS Framework
  • Use Databases with Ruby on Rails
English OK so we've got Ruby on Rails installed everything seems to be working good. Now it's time to start building out our app. So we're in the C rails test slash tester folder and we're done with the tester thing we don't want to use that anymore so we need to create our actual project that we're going to be using. So I'm going to use the CD command here to change directory into the C folder. Right. So now we want to create a new project directly in C where you can put it anywhere you want but I'm just gonna put it in C and I'm going to call it let's go rails new and then let's call this stocking and make a stock market app. Let's call it stalking. I don't know. So OK. Buh buh buh buh buh. It's doing all the things and it's running bundle install. We're not getting that message this time that says we need to update bundler or add bundler because we did that in the last video or whenever that was installing sqlite3 version 1.4 We get that same exact error but now we know how to fix that so we're good to go. So now we can CD into C stocking and you see this master thing we'll talk about that a little bit right now what I want to do is clear the screen and then ls we can see. We've got all of our files in here. So let's go ahead and open up our Sublime Text and go to project and then add folder to project and we just want to navigate to our C drive and then go down to that stocking directory we just created and then well we don't want to actually click it, click through, just highlight it and then click select folder then boom it adds all of our stuff. So just right away let's go ahead and make this sqlite change that we already know how to do and so we could paste this in save this or a comment that out save it. And another thing I'd like to do right off the bat with the gem file we're gonna talk about all these files in just a second here is see all these comments. I like to delete them because these are all the default things so we don't really care what the comments are read through them once if you want. But we do a lot of stuff in this gem file and having all these comments in here just seems kind of messy to me and OK so now if we save this you notice everything's nice and neat now and in the future whenever we want to add something we'll just add it right here and it just just seems easier to me. So let's see so we need to save this and then run bundle install to install this new sqlite thing here. Pull up our terminal and we are in C stocking. So we just type bundle install. We've already done this before once and it's gonna do this thing I'm just going to let it go and pull back up our terminal are a sublime text here. So for the rest of this video I won't spend just a couple of minutes talking about all of these files and all the stuff that you see here. So if this is your first time using Ruby on Rails this is going to be absolutely overwhelming. I get that first time I looked at all this stuff I was like What is all this. This is too much information overload going on. I don't know what all these things are. If you start to click on some of them boom they expand there's even more stuff like what is all this what you know what should we focus on. The good thing is most of this stuff we will never use. I've been doing Ruby on Rails for at least 15 years almost since there was a ruby on rails and I haven't opened or used most of those directories. You just don't you don't need to. I mean there may be a time in the future when you're doing some super advanced thing that you need to get into one of these folders and do something but for the most part we're just gonna use a few of them. So let's just go through here and start at the top and just kind of do a quick overview. So app is actually a directory that we will do a lot of stuff in and you can see the first directory in here as assets we expand that we see config images javascript and style sheets. And this is where we put just like they say if we have images that we want to use in our app we'll put them in this images folder if we have javascript code that we want to use we'll put it in this javascript file or folder if we have CSS style sheets that we want to use we'll put them in the style sheets folder and we'll go through and do all this stuff throughout the course but I just want to do a quick overview overview right now channels is not something that will likely ever use controllers is something we're gonna use Now Ruby on Rails is something called an M.V.C architecture model view controller and models are database stuff views are web pages and the controllers this thing right here sort of like the brains behind the scene we'll put like computer code like a lot of Ruby code in there if we need to. Controllers tend to kind of interact between the views and the database stuff so we will tend to use the controller stuff a little bit. I don't know how much we're gonna use it in this course but we may helpers probably won't ever use jobs probably won't ever use mailers probably won't ever use models there may be a little something we need to do database wise in there that we'll take a look at and finally views. This is where all of our web pages go. And so anytime we want to create a page we put it in the viewer folder here so that's it for app. Not too bad right. bin is likely something we'll never use config. There's a couple of things in here we might use. We're definitely in use this routes.rb file and we might use this environment thing here but maybe not otherwise. Same thing here. We might use we'll probably use the development and production these two files just for when we push our code up to Heroku for web hosting. We need to make a notation in there. So not much to be used in there. So let's see what was that config. So now we're down to D.B. this is where database stuff goes. The great thing about Ruby on Rails is it abstracts away the database stuff and does it all for you. So there's very little database stuff we have to do. But there may be a couple of things we need to look at there as we go on. Not too bad. Lib is nothing will ever use log is likely something we'll never use public. Never use that test. We won't use that temp. We won't use that and vendor we won't use that. So of all of these directories app is the big one that we're gonna use a little bit of config maybe a little bit of D.B. database but that's it. So then down here the gem file we've already looked at this. This is where we add third party code. You know if we want to use it we're gonna be using Bootstrap the CSS framework we'll add the bootstrap gem to this this file anytime we want to add something from the outside we do it in this gem file. So we'll start to we'll use that a lot of the rest of these things we pretty much ignore. So of all of this stuff there's really not a whole lot going on in here that you actually really day in and day out have to use. So if you're feeling overwhelmed Don't worry it's not as bad as it looks. And you don't have to memorize all this stuff. We're gonna start to use it slowly over time and as you use it you'll become familiar with it and it'll be just second nature you know. Oh I need to make a web page I'm going to go to apps views. It just it will. It will become apparent to you as you sort of start to play around with this more often. So not too bad. And hopefully you're not overwhelmed and if you are don't worry we're gonna take it nice and slow and it'll be fine. So that's all for this video in the next video we're going to run the server create our first web page. Take a look at all that stuff. And that'll be the next video.