Sunteți pe pagina 1din 6

Calgary Rails Workshop Windows Rails Installation About This Page

This is a slightly modified versions of the installation guide at DevChix wiki: http://www.wiki.devchix.com/index.php?title=WindowsInstaller_-_Rails_3

About Rails on Windows


These instructions should work for all versions of Windows from XP on to Windows 7. You may need to login as Administrator, or give the Administrator password when installing some programs, depending on your Windows version and user settings.

Install Rails
Go to http://railsinstaller.org/ and download the kit. This kit includes Rails, Ruby, DevKit, Git, and SQLite. Click on the downloaded file to run the install wizard. Click Next at each step to accept the defaults. Be sure to check the box for "Add executables for Ruby, Git and DevKit to the PATH"

Rails will be installed in C:\RailsInstaller and the directory for your Rails projects will be C:\Sites

From the Windows Start menu, go to Programs, RailsInstaller, Command Prompt with Ruby and Rails The first time you run this program, it will ask you to enter your name and email address. After doing this, test your Ruby install in the command prompt using the -v version flag ruby -v

You should see something like ruby 1.9.2p... Test your Rails install in the command prompt using the -v version flag rails -v You should see something like Rails 3.1.3

Open a Command Prompt


Much of using Rails is typing commands and hitting <enter>. Your experience using Rails on Windows greatly depends on your making friends with the command prompt window. Normally you will work in a command prompt window and keep it open along with your browser. This is also called the command prompt, command window, command-line window, MS-DOS or DOS window. Follow these instructions if you need to open a normal DOS window: Opening a command prompt window Rails Installer made a special DOS command prompt window for you to use when you're working on Ruby, Rails, or Git. To open the special Rails window, choose "Programs" on the Start menu, then choose "RailsInstaller" and then "Command Prompt with Ruby and Rails". You should do all your Rails work in this RailsInstaller DOS window. Try these recommendations: Recommended setup for command-line windows Tip: clear screen If you ever want to clear the "output history" to get a clear screen, type: cls Tip: command history The command prompt window stores a "command history." To view and re-run previous commands, use the <up arrow> and <down arrow> keys. You can also edit a previous command and run it--this is handy for long commands, or fixing mistakes. Tip: copy and paste

In the instructions below, where it says: "In the command prompt type:", you can, much more easily, copy the command from this page, and right click in the menu bar or command prompt window, then click on "Paste", then hit the <enter> key.

Install SQLite Manager


If you already have Firefox installed, verify that it is version 3.6.13 or greater. (Help -> About Mozilla Firefox. The version number is right under the "Firefox" title.) If you don't have Firefox installed, or it's an older version, install Firefox. Once it's installed, open Firefox and go to Tools -> Add-ons. At the top of the add-ons window, click "Get Add-ons." There will be search box directly underneath "Get Add-ons" that says "Search All Addons." Enter "SQLite" (without the quotes) in the box and hit enter. SQLite Manager should be the top result. Click "Add to Firefox..." (If SQLite Manager isn't in the results, check the spelling - SQLite only has one L. Also, check that you have at least Firefox 3.5.) Wait for the countdown, then click "Install Now." In the Add-ons windows, click "Restart Firefox." Once Firefox restarts, the Add-ons window should say "1 new add-on has been installed." Go to the Tools menu and verify that there is an option for SQLite Manager.

Install Editor
You can use any editor of your choice. Sublime Text is an elegant Windows editor. Your could also use Notepad++.

Create an ssh public key


You'll need one of these to create your Heroku account in the next section. open up Program Files, RailsInstaller, Command Prompt with Ruby and Rails. Be sure to use the same e-mail address that you used when you set up Git. $ ssh-keygen -C "Your Actual Email" -t rsa (email should match git config setting) Hit enter to accept blank passphrase (if computer is shared with other people, as in a work laptop, you should enter a passphrase). Hit enter again to accept blank passphrase (or enter passphrase again). Output of ssh-keygen command Your brand-new public key is now stored at YOUR_HOME_DIRECTORY/.ssh/ id_rsa.pub.

Create a Heroku Account


http://heroku.com -> Sign Up -> enter email address (use the same email as you did with git and the ssh public key). Heroku will send you an activation email. Open it and click on the activation link. It will take you to the Heroku site. Enter and confirm your password. Hit Save. If you have further heroku issues, try following these directions to install (or reinstall) the client.

Verify you can create a new Rails app


Open a Command Prompt with Ruby and Rails window and type the following with a return at the end of the line: rails new test_app The command's output is voluminous. :) Once that's finished, type the following in the Command Prompt with Ruby and Rails window with a return at the end of each line: cd test_app rails server The first command should produce no output. If "rails server" starts up with no errors, you're golden! It'll look something like this: => Booting WEBrick => Rails 3.0.0 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2010-09-30 21:04:12] INFO WEBrick 1.3.1 [2010-09-30 21:04:12] INFO ruby 1.9.2 (2010-08-18) [x86_64-darwin10.4.0] [2010-09-30 21:04:12] INFO WEBrick::HTTPServer#start: pid=24805 port=3000 If it does, congratulations! You've successfully installed Ruby AND Rails and started your server. (Here are some more diagnostics to try if it's not so smooth.) In your browser, go to http://localhost:3000 (screenshot of successful install) Back in the Command Prompt with Ruby and Rails window where you ran rails server, type control-c to kill(stop) the server.

Verify your database is set up


Open a Command Prompt with Ruby and Rails window. cd test_app

rails generate scaffold user name:string email:string address:text active:boolean rake db:migrate rails server In the browser, visit http://localhost:3000/users Click New user to create a user to make sure we can save to the database. (The window where you ran rails server will display debugging information as you do so.) In your Command Prompt with Ruby and Rails window where you ran rails server, type control-c to kill(stop) the server.

Verify git is working


Open a command Prompt with Ruby and Rails window. Type the following commands: cd test_app git init This should generate output similar to: Initialized empty Git repository in c:/Sites/test_app/.git/ Type the following commands: git add . (Note the dot) (May get line ending warnings; safe to ignore.) git commit -m "initial commit" (Output of initial check-in) git log (We're just checking to make sure it worked. Verify that it has the right user and commit message.)

Verify Heroku is set up


Install the heroku client: gem install heroku Create your Heroku app like this: heroku create --stack cedar Enter your Heroku email address and password. (Output of heroku create command) To verify that the heroku create completed successfully, type: git remote show and see if the list includes heroku. If you get messages here complaining about public keys it's probably due to some confusion with SSH key usage by another app on your computer. Call a volunteer over to help you figure it out. Luckily this only needs to be done the first time you create a Heroku app.

Edit your Gemfile and change the line: gem 'sqlite3' To this: group :development, :test do gem 'sqlite3' end group :production do gem 'pg' end Prepare your rails app for deploying to Heroku $ bundle install --without production Add the changes to git repository and push to heroku $ git add . $ git commit -m "Updates for heroku deployment" $ git push heroku master It may ask: "The authenticity of host 'heroku.com (75.101.145.87)' can't be established. RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad. Are you sure you want to continue connecting (yes/no)?" Type yes and hit <enter>. Output of successful first deploy. Be sure to find your Heroku application name in the output. (What to do if git seems stuck) In the Command Prompt with Ruby and Rails window type: heroku rake db:migrate (Output of heroku rake db:migrate) In the browser, go to your application's URL. You'll need your Heroku application name. The URL for your app is application name.heroku.com - so with the example output in the previous step, it would be floating-winter-18.heroku.com. Verify you see the welcome page. Leave this browser window open. In the browser, add /users to the end of the URL. Verify you see the user list page. Create a new user to verify you can write to the db on Heroku.

S-ar putea să vă placă și