Skip to content

Instantly share code, notes, and snippets.

@coder36
Last active December 25, 2015 06:58
Show Gist options
  • Save coder36/6935492 to your computer and use it in GitHub Desktop.
Save coder36/6935492 to your computer and use it in GitHub Desktop.
Rails notes

Initial Setup

Based on http://ruby.railstutorial.org/chapters/a-demo-app

gem install rails
sudo apt-get install nodejs`

Ruby requires a javascript runtime. This is provided by nodejs.

`

In the beginning...

Create a template project called quizzly:

rails new quizzly

This creates a rails template project under the quizzly folder. cd quizzly. From this point onwards, I'm assuming we're in the quizzly folder.

rake

To veiew all available rake operations: rake -T

Sqlite3

You can look at the created database with rails db:console or sqlite3 db/development.sqlite3

Use scaffold to create data structures

rails generate scaffold User name:string email:string

This creates a timestamped file called db/migrate/_create_users.rb . To apply this run:

rake db:migrate or to roll back rake db:rollback

`

Running

Start the server withrails server. You can connect to it using http://myip:3000

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