Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Creating hashes lesson on WINDOWS - from what application do you type this? Are you in the command line? IRB?

I am so confused by Ruby compared to PHP. For PHP everything was in XAMP and I would pull up a sublime text file. None of these Ruby lessons explain where you are launching this code from.....In the Creating Hashes lesson, what do you do to get to place where you can install gems? Do you open a sublimetext file? Do you open the command line? If yes, what directory do you go to? Do you type irb in the command line first? These lessons are super confusing and he seems to be in some application in Mac for the lessons where the prompts don't match anything I can find in Windows. Jason also types multiple lines of code - something I don't seem to be able to do unless I open a file and then run the file in irb which seems to be a workaround since he is coding mutiple lines on the fly. In my IRB i can only type one line at a time, If I hit return, it doesn't work. Ruby OMFG confusing.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

In this video, Jason is working mostly with IRB. This is how console looks like:

http://oi57.tinypic.com/dr6wch.jpg

You can tell it's a unix console by the $ symbol. the [~] means Jason is in his home directory, it would change if he goes into any directory. Yellow 1.9.3 is his custom prefix which tells him which version of Ruby he's using at the moment. It reads the value from a tool called RVM. You can customize your prompt any way you like in Mac and Linux. As another example, this is how my own prompt looks like in Linux:

http://oi57.tinypic.com/zjb6yr.jpg

It has Ruby version, the name of the git branch (red if some changes are pending, green if everything's committed) and path of my current folder, and of course the $ symbol indicating that it's the console. When Jason is using IRB, it looks like this:

http://oi59.tinypic.com/1086b11.jpg

You can tell by the > symbol preceded by line numbers (starting with 001). That's it, there's no more to it. And while it is possible to develop Rails apps under Windows, it's easier and more reliable under Mac and Linux (trust me, I tried).

You don't need Sublime in this lesson, although you can write this code in an .rb file and then run it in the console using ruby filename.rb command. It would do the same thing as running it manually in IRB. You install gems in the console and test the actual one-liners of code in IRB. If you need multiple lines, use Sublime and make .rb files and run them in the console using the ruby command, like I mentioned earlier.

As far as I can see, Jason never types more than one line of code in Creating Hashes lesson. He writes one line and hits enter, gets the result underneath.

I you want to stick with Windows, the only thing I can reccommend you is using CMDER (or Git Bash if you installed git package for Wndows) instead of Command Prompt/Terminal. It emulates some of the Unix commands and lets you follow the videos more or less under Windows. Don't blame Jason for this, it's just that most people don't seriously developRails apps under Windows, and Windows has its limitations, so there aren't so many great tools and compatibilities as there are for Mac and Linux.