Skip to content

Instantly share code, notes, and snippets.

@oguzbilgic
Created July 6, 2012 04:05
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 oguzbilgic/3058000 to your computer and use it in GitHub Desktop.
Save oguzbilgic/3058000 to your computer and use it in GitHub Desktop.
README.md scaffold for rails apps

MyApp

Very short description of the application.

1. Ruby, Rails & Rubygems

Applicatoin is written in ruby language, using Ruby on Rails web framework.

# This insalls ruby-1.9.2 on Debian based distros
$ apt-get install ruby1.9.2

Bundler is used to manage ruby dependencies, rubygems. To install all necessary gems use bundler.

# This installs bundler
$ gem install bundler

# This installs all the dependencies into `vendor/bundle` folder
$ bundle install --deployment

This application is developed using ruby-1.9.2, rails-3.2, bundler-1.1.4 and rubygems-1.8.24.

2. Database

Any database engine that is supported by ActiveRecord can be used, such as mysql, sqlite3 or postgresql. ActiveRecord is an ORM and it is one of the core components of Ruby on Rails.

2.1 Database Connection

To configure database connection define an environment variable like this:

# This uses `mysql2` adapter for the database connection
# Other adapters might require their gem to be pre-installed
ENV['DATABASE_URL'] = "mysql2://username:password@host/database-name"

or you can edit config/database.yml file to configure each environment database seperatly. It's default configuration is to use local sqlite database.

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

2.2 Database Migration

Once application is successfully connected to the database server, use this command to create and migrate the database:

# This creates a database
$ rake db:create

# This creates tables etc. on the database
$ rake db:migrate

2.3 Database Seed

Some of the database tables need to filled by initial data.

# This fills up the tables
$ rake db:seed

3. SMTP

To enable e-mail notifications, smtp server credentials has to be set up. These configurations can be set up through environment variables during the deployment process.

ENV['SMTP_SERVER'] = "smtp.example.com"
ENV['SMTP_PORT'] = 25
ENV['SMTP_USERNAME'] = "mail@example.com"
ENV['SMTP_PASSWORD'] = "pas$w0rd"

4. Assets

This version of Ruby on Rails uses Asset Pipeline. Therefore, in the production environment assets such as images, css and javascript have to be compiled.

# This compiles all the assets into `public/assets`
$ rake assets:precompile

5. Server

For the development easiest solution is to use:

# This starts WEBrick ruby server
$ rails server
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

or you can use rack's rackup command, since every rails application is also a rack application.

# This also uses WEBrick ruby server
$ rackup

WEBrick is part of the ruby's standart library and great as a development server, but there are plenty of other options to choose from for the production environment, such as:

in combination with Apache or Nginx.

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