1995 • Open Source • Remained relatively underused outside of Japan until Rails brought it to prominence (2003) • Cross platform (OS X, Linux and Windows) • RubyGems: package manager for Ruby (gem install rails)
by David Heinemeier Hansson (DHH) in 2003 (get it from github.com/rails/rails) • Developed with happiness and productivity of developers in mind • Beautiful and readable syntax (thanks to Ruby) • Favours convention over configuration (plural tables names, singular model names) • Don’t Repeat Yourself (DRY)
(no type declarations) • No brackets for simple method calls • Last statement of a method is automatically returned (18:09) costa:~/dev/apps$ irb ree-1.8.7-2011.03 :001 > def add(number1, number2); number1 +number2; end; ree-1.8.7-2011.03 :002 > add(1, 5) => 6
1..5 string ‘rails’ float 1.0 floating-point representation symbol :rails string for identifying purpose array [‘a’, ‘b’] list of objects, fixed order hash {:a=>1} Collection of key, value pairs
develop web applications • MVC (Model-View-Controller) architectural pattern • Predefined application structure • Rails was built with testing support in mind (test folder exists by default in the application structure) • Different environments within the same application (database.yml) • Active community and lots of resources to learn from
An object that wraps a row in a database table... and adds domain logic on that data (Martin Fowler) • Ruby classes that are located under app/models • One database table maps to one Ruby class • Attributes are columns • Associations between objects (A user has many blog posts)
<ul> <% @people.each do |person| -%> <li><%= person.first_name %></li> <% end -%> </ul> • Forms: Form Helpers / to HTML / to params / to ActiveRecord then validate attributes and save
Rails • Private APIs to Papers apps (Mac, iOS) • Different representational formats based on request types • Recommend papers to users based on criteria (for example: keywords or field of interest or job title)