Locked lesson.
About this lesson
Fixing the installation error we received by modifying the Gemfile.
Exercise files
Download this lesson’s related exercise files.
Gem File and Rails Server.docx60 KB Gem File and Rails Server - Solution.docx
57.6 KB
Quick reference
Gem File and Rails Server
In this video we'll fix the installation error we received by modifying the Gemfile. We'll also start the Rails server.
When to Use
Do this every time you want to run your Rails server to see your project live.
Instructions
To fix the installation error, modify the gemfile by changing this line:
gem 'sqlite3'
to this:
gem 'sqlite3', '< 1.4'
To run the Rails server from the terminal, type in this command:
rails s
Login to download- 00:04 And now it's time to actually open up our project and take a look at it.
- 00:08 So head back over to sublime.
- 00:10 And like we said you just go to your Windows Start menu, type in
- 00:14 Sublime, this thing will pop up.
- 00:15 And we want to come down here to Project, and then we want to Add Folder to Project.
- 00:22 And now, we just want to navigate to our C directory.
- 00:26 and then look for that pinteresting directory that we created a couple of
- 00:30 videos ago when we installed it.
- 00:33 And you don't want to actually double click it, you just want to click it once
- 00:37 to highlight it, and then click this Select Folder button.
- 00:40 And boom, boom, boom, all of the files in our project appear, very cool.
- 00:46 And now this is where we're going to be working pretty much for
- 00:49 the rest of the course, in this text editor.
- 00:51 And I'm going to go through here and
- 00:52 explain all these things a couple of videos from now.
- 00:55 For now we just want to click this GemFile button.
- 00:59 And this is a GemFile, I'll explain what this is later on.
- 01:02 But right now we need to fix that error that we got earlier.
- 01:06 And so we scroll down here and find this reference to the sqlite3 gem.
- 01:11 Remember, when we looked at that website, it said, I'll pull it back up.
- 01:15 It said that we need to change that reference to this.
- 01:18 So I just highlight here and click Copy, and then head back over here and
- 01:22 underneath here, I'm just going to right-click and click Paste.
- 01:26 And so you can see the difference between this,
- 01:28 we're just designating an earlier version.
- 01:31 So I can come up here and just delete this.
- 01:33 Now, hit Ctrl+S on your keyboard Cmd+S if you're on a Mac,
- 01:36 or you can come up here and click File > Save.
- 01:38 Finally, there's one more step it says, we need to run this bundle install command.
- 01:44 So I can copy this and head back to our terminal.
- 01:47 Make sure we're in this c/pinteresting directory.
- 01:51 We want to be in this directory from now on.
- 01:54 Any time we enter a command into the terminal, we'll do it in this directory.
- 01:58 So I could just right-click and click Paste, bundle install.
- 02:01 And any time we add a new gem,
- 02:03 we always have to install it by typing the bundle install command.
- 02:06 I'm kind of getting ahead of ourselves here.
- 02:08 But we'll get into all this much later.
- 02:10 But for now, this is just how we fix that error that we got when we installed
- 02:14 Rails And we should be good to go.
- 02:18 So we get this little thing, a warning message.
- 02:22 You get those sometimes when you bundle install, we can ignore this one.
- 02:26 And so I'm just going to go ahead and clear the screen and we're done.
- 02:28 We have successfully installed Ruby on Rails, but
- 02:32 we have all of our code here, I'm going to go ahead and close these files here.
- 02:37 Like I said, I'll get into all of this later.
- 02:39 There's one last thing we can do to sort of test to make sure that
- 02:43 our project was installed correctly, and that's to run the rails server.
- 02:48 So head back over to our terminal here, and just type in rails server, or
- 02:53 you can just type in rails s, rails is big on abbreviating commands, so
- 02:57 let's go ahead and rails s.
- 02:59 And what this will do is this will fire up Ruby on Rails internal web server.
- 03:03 So we can actually look at our project that we just created in a web browser, and
- 03:08 it's the Puma web server, we don't care about that.
- 03:11 We just need to make sure that it's running and
- 03:15 you can see down here it says localhost:3000.
- 03:19 Highlight this and copy it and then pull back our web browser and
- 03:23 just paste that in.
- 03:26 And if everything went according to plan,
- 03:29 you should get this cool little Rails welcome page.
- 03:32 And this is just the default Rails page that lets us know that our project was
- 03:36 installed correctly, everything is working, and it's very cool.
- 03:39 We'll go ahead and change this page later on to our own web page,
- 03:43 whatever we want to build.
- 03:45 But for now we just want to see that it was installed correctly if
- 03:48 you get this little picture on here.
- 03:49 It means it worked, everything worked fine.
- 03:52 The error message that we fixed has in fact been fixed.
- 03:55 And everything is good to go.
- 03:57 Now, I should mention, anytime you want to run your app,
- 04:01 you have to type this rails s command.
- 04:03 And some people just keep this running, this Git Bash terminal running all
- 04:08 the time, and then just open up a second one in order to type in commands.
- 04:12 because we're going to be typing in a lot of commands into the Rails terminal.
- 04:15 And it's kind of a hassle to hit Ctrl+C to break out of this,
- 04:19 type in your command and
- 04:20 then run the rails server again anytime you want to take a look at your website.
- 04:25 Because if it hasn't been running, if it's not running, you hit reload.
- 04:30 Well, it is running now.
- 04:31 If I hit Ctrl+C break out of it, and then hit reload here.
- 04:36 We're going to get an error that says, this site can't be reached.
- 04:38 That's just because the web server has stopped.
- 04:40 So personally I just run the Rails server always and then I'll go ahead and
- 04:44 just go to my Windows start menu and create another instance of
- 04:48 the Git Bash terminal and just type my commands into that.
- 04:51 You just want to make sure that when you do that you're
- 04:54 in the c/pinteresting directory.
- 04:56 And you just do that by typing in cd, and then that c/pinteresting directory and
- 05:00 you should be good to go.
- 05:02 We are now ready, we're actually ready to create our project and
- 05:05 actually start coding and doing all the fun things.
- 05:09 It's kind of a hassle to install Ruby on Rails but I don't think it was too bad.
- 05:13 Once you've done it once, you can do it again very easily.
- 05:15 You don't have to install rails every time you create a new project.
- 05:19 You just use that rails new command and spin up a new project, so
- 05:23 the hard part is all over.
- 05:25 In the next video want to spend a few minutes talking about the MVC concept.
- 05:30 It stands for Model View Controller, Rails is a model view controller platform.
- 05:35 And so I'll spend a couple of minutes talking about that.
- 05:36 From now on I'm going to be using a different development tool in the videos.
- 05:40 I'm going to be using something called Cloud9, C9, and it's a cloud development
- 05:45 tool that has the text editor, the terminal and the server all in one screen.
- 05:49 You guys should follow along and use the tools that we just setup and installed.
- 05:53 Actually Amazon bought this company Cloud9 couple of years ago and
- 05:57 they've since closed it down.
- 05:58 So it's not available for use to the public, so
- 06:00 you going to have to use the tools that we just downloaded and installed.
- 06:03 So that will be starting in the next video.
Lesson notes are only available for subscribers.