Setting up Ruby on my PC


#1


EXERCISE: NOT APPLICABLE

I am trying to install ruby and rails on my computer, but it's not working. I downloaded the most recent version of ruby, and I believe I installed rails, but I keep getting error messages, and nothing works. For a beginner, this is really frustrating, because I can't even get off the ground.

Is there an easier way? Any ideas why I'm getting errors?

Thank you.


Replace this line with your code.


#2

Maybe @zystvan could help or help refer another. :slight_smile:


#3

@monroemann What operating system do you use, and how did you install Ruby?


#4

Hello! Thanks so much for responding.

I have Windows 10 on a Surface Pro.

I just went to http://railsinstaller.org/en and downloaded with their all in system.

I'm just disappointed because I bought a book on how to set up ruby and rails, and I do exactly what it says, but it doesn't work. I just checked the copyright, and it's from 2007--I bet a lot has changed since then.

I just remember when I was a kid, I learned some visual basic, and the thing that always frustrated me is that I could never 'compile' the programs and 'launch them'. I thought maybe Ruby on Rails would finally allow me to make a program and launch it, but just getting this all set up is again a nightmare. I'm good at coding and I understand all the logic, but I just can't figure this part out at all.


#5

So I think Ruby and Rails both installed correctly now, but I still don't know where I'm supposed to code anything. Certainly not in the command prompt. And where to store the controllers and all that?

I'm in the middle of the Ruby course now, but it seems to only focus on coding itself. Is there a course here that shows me where to actually code, and how to run the programs, and how to launch them on the internet? I'm absolutely willing to pay a subscription fee if someone can help me with this.

Thank you.


#6

http://rubyinstaller.org is where you'll find your download for ruby on windows. As for Rails, you can download that from their website or as a gem. Gems (and the tool for installing gems) can be found on http://rubygems.org.

To actually code, all you do is open a text editor (notepad++, sublime text, ect) and write some code, and save it under the extension .rb.

To run it you should just have to either run it as you would any other program, or by using the command promp (I recommend this one). You might have to do something like

ruby Example.rb

for it to run, although I haven't experienced this.

Have fun. :]

Edit: Also, for your rails project, I recommend making a newfolder and storing all your rails stuff in that. There's some tutorials put there that can help you more with it than I can.


#7

Thanks very much.

Where, however, do I save the .rb files?

And how would I execute the files in a web browser?

Thanks!
-Monroe


#8

You don't execute regular ruby files in a browser, those are .erb files. Saving the file isn't hard, you just save it like any other file, just put .rb as the file extension.


#9

Perhaps I'm not being clear: I know how to save a .rb file, but ruby has to know where to find it, and so how do I save it in a place Ruby will find it?

And as for .erb files: the Ruby program I want to make is for the web. I'm trying to find out how I'd test the program in a browser, so I can see how it would look for a web user.

Thanks much!
-monroe


#10

As long as ruby is on your PATH, ruby will find the file and execute it no matter where it is. As for how to run the .erb files in the browser, althought this is venturing out of my expertise, you will need to generate a controller and a view. The view is the erb, so you can use the <% %> tags to code and do everything you want.

To do it without rails..well, look it up on SO. I can't help there.


#11

You'll be telling ruby or rails what to run, you can save them anywhere. A good place would be in a subdirectory to your home directory. You would then open up a command line interface, navigate to that directory, and start typing commands.

You need to install ruby, there's some site rubyinstaller for doing that on windows
When you've done this, confirm that it has been added to your PATH variable by running

ruby -v
gem -v

If they both output version numbers then you can continue to install rails with

gem install rails

And then you can check if that's installed properly with

rails -v

Again, you'll want a version number to be printed.

If any of those fail, you'll need to check that they were installed to your system and are in your PATH variable. The details for doing that on your OS is something you'll find with your favourite search engine.

After that's all done, navigate to the directory of your project which can be anywhere you want - and start typing commands.


#12

Thanks very much!

version numbers were outputted with each command.

How then can I create a directory? Just like creating any old folder in Windows? As easy as that?


#13

Yep, any old folder.