Skip to content

Use RVM to install Ruby1.9.2 and Rails3.0.9

judytuna edited this page Sep 9, 2011 · 2 revisions

Install RVM (and use it to install everything else)

Stuff in this section is from http://ruby.railstutorial.org/chapters/beginning#sec:rubygems

Install rvm.

user$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

(source: https://rvm.beginrescueend.com/rvm/install/ )

Next, tell your rvm not to download the rdoc and ri stuff when you're installing and updating gems. Open up (well, create) your ~/.gemrc file and make it say:

install: --no-rdoc --no-ri
update: --no-rdoc --no-ri

(source: http://beginrescueend.com/gemsets/basics/ )

Install ruby 1.9.2.

$ rvm install 1.9.2

Make a new Gem Set (I called it rails309), set it to the default, and use it.

$ rvm --create use 1.9.2@rails309
$ rvm --default use 1.9.2@rails309

Install rails 3.0.9.

$ gem install rails --version 3.0.9

(Do this parenthetical stuff only if you're deploying to heroku. Install the heroku gem. Do all of this stuff: http://ruby.railstutorial.org/chapters/beginning#sec:1.4.1 . In particular, do

$ gem install heroku

then you have to tell it about your ssh keys.)


Get my project from github.

cd to the directory that my project lives in. Make sure that Gemfile (in the project directory) already looks like this: http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#code:final_gemfile

Then while you're in the root of the project directory, type this:

$ bundle install
$ bundle install --binstubs

to get all the other gems you need. Then the project should work.

To start the local server, type this:

$ rails server

Then point your browser to http://localhost:3000/ & verify that it's working.

To populate your database with shit, type this:

$ bin/rake db:migrate
$ bin/rake db:populate

(What does this mean? "migrations" are instructions that add columns to the database and are part of Rails. "populate" is something we wrote ourselves as part of the tutorial, and it fills the database with 100 random users using the gem "Faker".)

You can look at the user database with the console. Get to the development environment console like this:

$ rails console

Then type

> User.first

Or you can look at users using stuff like

> User.find(38)
> User.find_by_email("[email protected]")

In my current "populate" setup, the first user gets turned into an admin user. You can see that when you go User.first (the last thing in says admin: true ). You can turn any user into an admin user like this...

> judylol = User.create!(:name => "Judy T", :email => "[email protected]", :password => "foobar", :password_confirmation => "foobar")
> judylol.toggle(:admin)
> judylol.admin?

Or, you know, substitute whatever in the "create!" thingy. In this case, "judylol" is just a variable I'm using in the console, it doesn't mean anything. And then you can go back to http://localhost:3000 in your web browser, log in as your new admin user, and see the pretty Delete links and stuff. haha. So yeah I don't have a way of setting users as admin except in the rails console yet haha

Clone this wiki locally