Installing a Ruby on Rails Development Environment in Windows12:14 with Jason Seifer
In this video, you'll learn how to install a Ruby on Rails Development Environment in Windows.
git config --global user.name "Jason Seifer" git config --global user.email firstname.lastname@example.org
Download and Install MySQL
MySQL can be downloaded from the MySQL Download Page.
Create a new app
mkdir projects cd projects rails new testapp cd testapp subl -n . bin\rails server
Create a quick scaffold
bin\rails generate scaffold name title:string first:string last:string bin\rake db:migrate bin\rails s
Hi, I'm Jason, the Ruby teacher here at Treehouse. 0:00 In this workshop, 0:03 we're going to set up a Ruby on Rails development environment in Windows. 0:04 We're going to download and install Ruby, Cmder, 0:08 a few different databases, a text editor, and a couple other different dependencies. 0:12 Next, we'll generate a quick Rails application to make sure everything's 0:18 working and test it out in a web browser. 0:21 Now, let's go ahead and get started. 0:23 Okay, so let's go ahead and 0:26 install Ruby on Rails development environment on our Windows computer. 0:28 Now, for demonstration purposes here, I am using Windows 10. 0:33 This is a preview release of Windows 10, but 0:37 these instructions still apply from Windows 7 up. 0:40 Now, the first thing that we need to do is download and install Ruby. 0:43 So, I'm going to use Google Chrome to head over to the RubyInstaller downloads page. 0:48 This is it, rubyinstaller.org/downloads. 0:54 You can also find this in the notes right below the video here. 0:58 So, go ahead and click on Ruby 2.1.6. 1:02 Now, you'll see there are differences. 1:07 One says x64 and one does not. 1:09 The x64 means it's for a 64-bit version. 1:13 If your Windows is x64, then go ahead and grab the x64 version. 1:19 This actually applies to most software that you will be using. 1:25 Once that finishes downloading, head on over to your Downloads folder and 1:29 double-click it, and press Run. 1:33 Click I accept the license after fully reading the terms of the license. 1:39 And then also make sure to check this button, Add ruby executables to your PATH. 1:46 Now, I'm backing out the -x64, and 1:50 just installing this to the Ruby21 directory on the C drive. 1:54 Then, press the Install button. 2:00 Okay, great that finished. 2:04 The other thing that we need to download from the RubyInstaller page 2:06 Is something called the dev kit. 2:11 This is going to make it easier to install certain other RubyGems and 2:14 libraries that we might need. 2:19 Now, I'm using the x64 version. 2:21 So, I'm going to grab this one, which is for use with Ruby 2.0 and 2.1. 2:24 We downloaded 2.1. 2:30 Now, the reason that we downloaded 2.1 as of the recording of this screencast, that 2:33 is the best version of Ruby to use with Windows mainly for compatibility reasons. 2:39 Now, once again go back to the folder where it downloaded. 2:47 Double-click and type run. 2:50 Now, I'm going to extract this to 2:53 the DevKit directory inside of the Ruby installation that we just created. 2:56 That is not created by default, so I'm gonna have to type it in. 3:01 Ruby21\devkit. 3:05 And then, press Extract. 3:09 Then go ahead and wait for all these files to extract. 3:11 Okay, there is another installation process that we do need to do for 3:16 the DevKit, and we're gonna get right back to that. 3:19 First, we're gonna download, something that is not entirely required, 3:23 but does make things a lot nicer, and that's called Cmder. 3:28 And this is a console emulator for Windows. 3:32 It also includes some other dependencies for 3:36 us that make developing with Rails a little bit easier. 3:38 Let's go ahead and hit Download full. 3:42 Okay, once Cmder finishes downloading, go ahead and 3:45 inside of that folder, press Extract All. 3:49 I'm just gonna leave it in this directory. 3:55 [BLANK_AUDIO] 3:56 And that will go ahead and extract. 3:59 So once Cmder finishes, go ahead and double-click it to open it. 4:03 You can add this, or pin it to your Start Menu. 4:08 Now, go ahead and click on Run. 4:12 [BLANK_AUDIO] 4:14 And we get this nice emulator window. 4:18 Okay, so once we get Cmder up and running, now we can start to install some things. 4:23 First, open your web browser back up and 4:30 go over to rubygems.org. 4:33 We need to install a couple of different gems that Rails needs in order to start 4:38 creating Rails applications. 4:43 And this is just a Windows specific thing that we need to do. 4:45 Click on SQLite3, and then notice we have different versions of SQLite3. 4:50 Click Show all versions. 4:57 Now, depending on whether you downloaded the regular or 5:00 64-bit version of ruby, that's the version that we need to see here. 5:04 So, grab the latest one. 5:08 I am going to be using the x64 version of 1.3.10. 5:10 Scroll down on the right side of the screen, click on Download. 5:16 This contains a precompiled version of different Ruby libraries that we'll need. 5:22 The next gem that we need to download is called Nokogiri. 5:29 And just like before, click show all versions, and 5:38 then get the most recent version. 5:41 It says x64. 5:46 Then scroll to the right and press Download. 5:48 Now I'm gonna minimize this and head back to our Cmder console. 5:53 I'm in the user's Jason Seifer directory. 5:58 So now, I'm in the Downloads directory, 6:02 which is where we just downloaded these gem files. 6:05 Now, type, gem install. 6:09 And you can start typing the name of the gem you downloaded. 6:12 I typed s and q, and then pressed tab. 6:17 And click allow access for the Ruby interpreter to do network installation. 6:22 Then do the same thing with the Nokogiri gem. 6:29 While Nokogiri's installing, we're going to setup some other dependencies for 6:34 our Rails environment. 6:39 I'm going to download the Sublime Text text editor. 6:42 This is not a requirement. 6:49 If you have a text editor that you like more than Sublime Text, you can use that. 6:51 This is just for demonstration purposes. 6:57 [BLANK_AUDIO] 6:59 And I'm going to allow this app to make changes to my PC. 7:03 I'm also going to add to the explorer context menu. 7:07 [BLANK_AUDIO] 7:11 Okay, so, Sublime Text is now installed. 7:13 Looks like Nokogiri is still working. 7:17 In the meantime, I'm also going to download MySQL for Windows. 7:21 [BLANK_AUDIO] 7:26 Now, we'll have a link in the notes right below this video to download MySQL for 7:37 Windows. 7:41 [BLANK_AUDIO] 7:42 And you can click, No thanks, just start my download. 7:45 Now, it looks Nokogiri has finished installing. 7:51 Let's go ahead and launch Sublime Text. 7:54 Now, we're going to create a File, 7:59 and type, gem: --no-document. 8:04 [BLANK_AUDIO] 8:09 Now save this inside of your user folder. 8:12 [BLANK_AUDIO] 8:16 And call it .gemrc. 8:21 This is going to tell RubyGems to not install the documentation for 8:26 gems that we install on the command line. 8:30 That's also not necessary to do, but it does speed up gem installation. 8:35 Now, I'm going to install a couple gems using the command line. 8:40 I'm going to install Bundler, which is a gem that rails needs. 8:45 And now I can install Rails. 8:50 This is going to take a little while. 8:55 Now that Rails has been installed, let's go ahead and check on our MySQL download. 8:58 It looks like that has finished downloading. 9:03 [BLANK_AUDIO] 9:06 And we do wanna allow this program to make changes to our computer. 9:15 [BLANK_AUDIO] 9:18 Go ahead and click full install. 9:22 And then click Execute. 9:27 We don't need to worry about this failure right now because it's not going to 9:30 impact our Rails applications. 9:33 Click Next and make sure that Development Machine is checked. 9:35 Choose a root password. 9:39 Make sure that you remember it. 9:44 And also, start the MySQL server at system startup. 9:46 Depending on your version of Windows, you might get a message 9:52 saying that the service list has changed, it's okay to dismiss that notification. 9:55 Now click Next and make sure to check your route password is correct, and 10:02 then click Next. 10:06 At the Apply Server Configuration screen, press Execute, and then click Finish. 10:08 Click Next, and then click Finish. 10:16 Now tab back to Cmder. 10:19 We're almost ready to configure everything. 10:21 Now I'm going to change back a directory, so now I'm in my regular user folder. 10:24 And I'm going to also change into the documents folder. 10:30 We're about to generate our Rails application. 10:34 First, let's go ahead and configure Git, which comes with Cmder. 10:37 [BLANK_AUDIO] 10:40 I'm gonna configure my username, which is Jason Seifer. 10:45 And I'm also gonna use this global command to configure my email address. 10:50 [BLANK_AUDIO] 10:55 I'm finally ready to create my Rails application. 10:59 I do that with the rails command, rails new, 11:02 and then the name of the application, in this case it's going to be example app. 11:06 Now if we get this error saying the, json native gem requires the installed 11:12 build tools, it's because we forgot to install the DevKit. 11:16 So, go back to the Ruby21 directory and DevKit. 11:21 And then type, ruby dk.rb init. 11:28 And then, ruby dk.rb install. 11:34 [BLANK_AUDIO] 11:37 Now, we can go back to our documents directory, and 11:42 the example app directory, and type bundle. 11:45 Now that that's done, type rails server. 11:50 Now, let's go back to our web browser. 11:55 And go to localhost on port 3000. 12:00 And now, we've installed a Ruby on Rails development environment. 12:05
You need to sign up for Treehouse in order to download course files.Sign up