Skip to content

Instantly share code, notes, and snippets.

@afshinator
Last active December 31, 2015 19:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save afshinator/8035821 to your computer and use it in GitHub Desktop.
Save afshinator/8035821 to your computer and use it in GitHub Desktop.
Building TheOdinProject on Nitrous.io-- https://github.com/TheOdinProject/theodinproject --A lot of us are choosing to develop on nitrous because it makes a lot of dev environment issues go away - not all of them though.This gist is a step-by step recipe to follow along with the 'Hacking on the Site Yourself' instructions in the project README. …
Getting THE ODIN PROJECT running on Nitrous.io
(with Postgresql, ...)
- Especially if you have a windows box, fugget-about-it!!! Just use Nitrous and you'll be well enabled.
- Step numbers below correspond to Eriks steps in 'Hacking on the Site Yourself' at:
https://github.com/TheOdinProject/theodinproject
Read those instructions at the same time for context.
1. A new Nitrous box sets you up with Rails 4 and Ruby 2; dont worry, we'll be addressing that.
[ As of Feb 2014, the Odin Project has been upgraded to use Rails4 with Ruby2.]
2. Fork the Odin Project, git clone your fork down to your Nitrous box, for me that looks like:
git clone https://github.com/afshinator/theodinproject.git
Do not 'cd theodinproject' quite yet...
Before we 'bundle install' we have to take care of the Ruby version issue,
the Rails version issue will take care of itself.
[ ------------ News Flash! -------------
Since the upgrade of the project to Rails4/Ruby2, you can skip straight to jumping into
the directory, and 'bundle install' as per step 3 below....
I believe the gemset is now automatically being created,
Note you might get a warning about the version of Ruby 2 not matching, dont worry about it.
]
[ ----------- Older info for when the project was still under Ruby 1.9.3, Rails 3 :
rvm makes it easy to switch between ruby versions. Do the following
rvm list # will show something like ruby-2.0.0-p247 with a '*'
next to it indicatting currently selected
If for some reason you are seeing multiple lines of output, showing multiple versions of Ruby on your box,
if the '*' is already next to 1.9.3, then you know that version is installed and currently selected for use,
if the '*' is NOT next to 1.9.3 you can select it for use with 'rvm use 1.9.3' ; (but dont yet)
If 1.9.3 is not in the list, which it shouldn't be in a spanking new Nitrous box, you need to install it first, so
rvm install 1.9.3 # will not take long to finish
For kicks, do a 'rvm list' just to see your new list of available ruby versions;
The '*' should still be next to ruby 2.0.0 as currently selected.
Now change into the project directory:
cd theodinproject # rvm should pick up from the Gemfile to switch to 1.9.3,
It should give you a message about recognizing your ruby version needs.
'rvm list' should reveal now you're using 1.9.3 instead of 2.0.0
If this is not the case, I'm not sure why! You might have to manually do 'rvm use 1.9.3'
You're essentially set to go, but lets create a gemset for this project.
rvm gemset create theodinproject
rvm gemset use theodinproject
You can verify you're good to go by going back and forth between your root and theodinproject directories,
do a 'rvm list' in each one to see that the environment switched the currently selected ruby version for you. Nice!
]
3. Run 'bundle install', enjoy watching the copious output, don't worry about nokogiri taking so long.
4. Rails defaults to sqlite3 for the dev environment; Nitrous makes switching to Postgresql easy:
(if you want details : http://help.nitrous.io/postgresql/ )
Do NOT run 'rake db:create', yet.
Lets install Postgresql:
parts install postgresql # Will not take long
Start it up:
parts start postgresql # YOU'LL NEED THIS AGAIN & AGAIN IN THE FUTURE...
Memorize that last command because you'll have to do it everytime you go away from your nitrous box, it goes into
idle mode, and you have to restart it. You'll likely forget this at least once or twice.
[ ------ March 2014 update: Nitrous starts it up automatically for you now on subsequent logins. ]
Now here is the part of the whole process that bothers me; I've gotten different results at different times...
and I'm not sure why. I could swear 'rake db:migrate' at this point worked for me before, but the last time
I had to this it failed, so first I had to:
rake db:create # as of Feb 2014 I no longer see error output!
Which produced a whole bunch of error output! Could not connect to server, Could not create db, etc...!! :-(
But after this, the next step works!! :-)
5. 'rake db:migrate' should now suceed, go for it.
After its done, you should be able to 'rails s', go to port 3000 and see the website...
...though its not filled with the curriculum yet.
Stop the server if you started it.
6. & 7. Do this stuff in this order,
rails g figaro:install # Creates config/application.yml and appends .gitignore
Go to https://github.com/settings/applications and create your personal access token, give it any name, copy it
Add this to the config/application.yml file:
GITHUB_API_TOKEN: 9zzac77376babcdefghab509729c654321f5x # Use the token you created, not the one I put here!
Seed the database
rake db:seed
Finally:
rake curriculum:update_content # Watch it get all the lessons.
You'll get an ALL DONE message. Kickstart your server and go check it out, now you have all the content.
"That... should... be... it...?" -Erik
@afshinator
Copy link
Author

REMEMBER:

parts start postgresql

Have to do this everytime you step away for a while, come back and have to re-start your box... or else you'll get:

could not connect to server: No such file or directory...
Is the server running locally and accepting connections...

@tarabusk
Copy link

For the very dumbs and/or new to Nitrous, the line:

GITHUB_API_TOKEN:my_github_key

... is not a command line.
This line has to be added in the config/application.yml by modifying directly this new file.
You'll find it going on the IDE of your box.
(I made all the operation on the terminal interface, and for a moment couldn't find the way to add that line)

Everything went well for me ! Thanks Afshin.

@afshinator
Copy link
Author

==== Deploying to Heroku (via Nitrous)...

You need to do:
heroku keys:add ~/.ssh/id_rsa.pub

Before:
git push heroku master

But as of Rails 4, you still wont get the default rails page until you add a root route,
see (Hartl's book section 1.4.3 for root route issue and http://help.nitrous.io/heroku-rails/ )

@amlee
Copy link

amlee commented Aug 13, 2014

try "bundle install" on the Nitrous console but got:
.
.
Using capybara 2.0.2
Using json 1.8.1
Killed

It's still missing some packages since running "rake db:create":
Could not find capybara-webkit-1.1.1 in any of the sources
Run bundle install to install missing gems.

@sevaccount
Copy link

Hi. What does "fork the Odin project" mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment