Skip to content

Instantly share code, notes, and snippets.

@lucamartellucci
Last active March 11, 2016 15:15
Show Gist options
  • Save lucamartellucci/8138ee19596551db24b8 to your computer and use it in GitHub Desktop.
Save lucamartellucci/8138ee19596551db24b8 to your computer and use it in GitHub Desktop.
Ruby on Rails

##Install Ruby on Rails

Refer to this tutorial: Install Rails on Ubuntu

Create a Rails application

Scaffold a new application

Here’s how to create a project-specific gemset, installing Rails, and creating a new application.

$ rvm use ruby-2.1.2@myapp --ruby-version --create
$ gem install rails
$ rails new .

Scaffold an entity

The following code shows how to scaffold for a simple entity called "post" with two attributes:

  • title of type string
  • body of type text
$ rails generate scaffold post title:string body:text

To propagate the effect of the scaffold to the database use the follow command:

$ rake db:migrate

To show the routes handled by the application (also this part is generated by the scaffold mechanism) use the command:

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