Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Jordan Pierre
Jordan Pierre
16,723 Points

Where should I be writing my ruby code?

Hello Everyone,

I am still in the beginning stages of ruby and I'm a little confused about where I should be writing my ruby codes. I some of the exercises I was writing code in irb on my console. And then sometimes the instructor switches to a text editor such as Sublime Text. Should I be writing my code in Sublime Text, Xcode, or irb?

6 Answers

Xcode is used for mainly iOS and OS X development, not ruby (although I believe it is possible, maybe have a look at MacRuby). IRB is convenient, but writing more than one statement at a time gets kind of hairy. In my opinion IRB is really a learning tool, its not really designed to have large amounts of code written in it. I prefer just using sublime text

Jordan Pierre
Jordan Pierre
16,723 Points

Thanks for the quick response. Now I have a follow-up question. I am working on the methods badge in ruby basics. The instructor typed in:

touch simple_methods.rb

and then

subl simple_methods.rb

I then got this message

-bash: subl: command not found

So Im assuming he did this to open and save a new ruby file. And I'm not sure why I got that error message but when I opened the file using my desktop, it opened as an Xcode file.

In mi opinion always text editor + terminal is the best option.

+1 for Sublime Text.

subl is a command line for sublime text. looks like its not installed or it is not sublime text 2 I think in 3 they changed the command line executable name.

Jordan Pierre
Jordan Pierre
16,723 Points

Thanks Justin, I did have the first version of sublime and not 2 or 3 installed. What does touch command mean? And I updated to Sublime 2 I still get the -bash: subl: command not found error message

Well from the command prompt if you issue a "which subl". Does it come back with anything? Sounds like either it did not get installed of for some reason is not in your path.

Touch is a *nix command that creates and empty file or can be used to update the atime of a files attributes probably why it's called "touch" :-)

I've been using TextMate 2. I have it set up so I just type: mate file_name.rb and it will create the file and open it for me right away. P.S. This is all extremely new to me. I don't even remember how/why I ended up using TextMate instead of Sublime.