It is impossible not to notice Ruby on Rails. It has had a huge effect both in and outside the Ruby community… Rails has become a standard to which even well-established tools are comparing themselves to.

~ Martin Fowler, Author of Refactoring, PoEAA, XP Explained

Anatomy of a Ruby on Rails Application

An introduction to software development using the Ruby on Rails framework

Andrew Briening (abriening)

Content

  • What is Ruby?
  • What is Rails?
  • Why should I care?
  • Creating a Rails project (code examples)
  • Tools & Techniques

Rails is an application framework

  • For building web-browser-based applications
  • For building REST APIs
  • Tools to ease development of these applications
  • Easy to extend the functionality for custom features
  • Convention over configuration

Ruby is the language

  • Object Oriented
  • Dynamic language (interpreted, not statically typed)
  • Principled (POLA, KISS)

Why should I care?

  • Community
  • Open-source
  • Promoting security best practices
  • Promoting development best practices

Let's create a new application





                        rails new [project]



          

Rails Skeleton - /[folders]


├── app
├── config
├── db
├── lib
├── log
├── public
├── script
├── test
├── tmp
└── vendor

Rails Skeleton - /[files]


├── Gemfile
├── Gemfile.lock
├── README.{rdoc,md,textile}
├── Rakefile
└── config.ru

Rails Skeleton - /app


├── app
│   ├── assets
│   │   ├── images
│   │   ├── javascripts
│   │   └── stylesheets
│   ├── controllers
│   ├── helpers
│   ├── mailers
│   ├── models
│   └── views
│       ├── layouts
│       │   └── application.html.erb
│       └── ...

Rails Skeleton - /config


├── config
│   ├── application.rb
│   ├── boot.rb
│   ├── database.yml
│   ├── environment.rb
│   ├── environments
│   │   ├── development.rb
│   │   ├── production.rb
│   │   └── test.rb
│   ├── initializers
│   │   ├── inflections.rb
│   │   ├── mime_types.rb
│   │   └── secret_token.rb
│   ├── locales
│   │   └── en.yml
│   └── routes.rb

Rails Skeleton - /db


├── db
│   ├── development.sqlite3
│   ├── migrate
│   │   └── 20120816010724_....rb
│   ├── schema.rb
│   ├── seeds.rb
│   └── test.sqlite3

Rails Skeleton - /test


├── test
│   ├── factories.rb
│   ├── fixtures
│   ├── functional
│   │   └── ..._test.rb
│   ├── integration
│   ├── performance
│   ├── test_helper.rb
│   └── unit
│       ├── ..._test.rb
│       └── helpers
│           └── ..._helper_test.rb

Tools & Techniques

End