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

bin/rails generate controller user_friendships

I'm working on the ruby on rails social network module...

I don't understand why I'm typing in bin/rails

I've done a few other rails tutorials before, and I've never done this before when generating models or controllers.

What does it do, and is it necessary?

Will it break my code if i just do rails generate controller user_friendships?

2 Answers

Jim Hoskins
STAFF
Jim Hoskins
Treehouse Guest Teacher

Sometimes the globally installed "rails" may not be accessible, in which case there is another copy stored in your project's bin/ directory. As for why Jason used bin/rails ... instead of rails ... I'm not sure of the exact reason.

You should be fine to use "rails" in stead of "bin/rails", unless there is some detail I am unaware of, which is entirely possible. I'll ask Jason.

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

In an earlier lesson, we run the bundler command with the "--binstubs" flag. This sets up our project with a "bin" directory which contains executable files that run the commands specific to the application and ignore other gems. This is useful if we have more than one version of Ruby or the gems installed which is a possibility on any system, especially since Mac OS X comes with an out of date Ruby and Rails installed.

It's the same running "bundle exec" before each command. Check out the bundle-exec page for more information:

http://gembundler.com/man/bundle-exec.1.html