O documento discute a filosofia do framework Ruby on Rails. Ele descreve como Rails promove convenções sobre configurações e o princípio de "não se repita" para facilitar o desenvolvimento ágil e a manutenção de código. Além disso, destaca como Rails permite que times pequenos construam e mantenham aplicações complexas de forma rápida e divertida.
91. class Admin::PostCategoriesController < ApplicationController
def index
@categories = PostCategory.all
controller
respond_with @categories
end
def show
@category = PostCategory.find(params[:id])
respond_with @category
end
def new
@category = PostCategory.new
respond_with @category
end
def edit
@category = PostCategory.find(params[:id])
end
def create
@category = PostCategory.new(params[:post_category])
flash[:notice] = 'Category was successfully created.' if @category.save
respond_with @post
end
def update
end
def destroy
end
end
100. Eles servem mais de 23 milhões de visitantes/mês. A
conversão resultou em 20 mil linhas de Ruby em vez
de 125 mil linhas de Java
101. Eles servem mais de 23 milhões de visitantes/mês. A
conversão resultou em 20 mil linhas de Ruby em vez
de 125 mil linhas de Java e, mais importante, facilitou
a dificuldade que tinham em manutenção.
102. “Eles servem mais de 23 milhões de visitantes/mês. A
conversão resultou em 20 mil linhas de Ruby em vez
de 125 mil linhas de Java e, mais importante, facilitou
a dificuldade que tinham em manutenção. Eles
também finalizaram a reescrita do sistema em apenas 3
meses com 4 desenvolvedores. Uma vez completo e
otimizado, o site deles agora é mais rápido que antes.”
http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails
116. set :application, "producer"
set :ip_address , "208.88.125.20"
deploy.rb
# GIT SETTINGS
set :scm, :git
set :repository, "git@github.com:danielvlopes/producer.git"
set :branch, "master"
set :deploy_via, :remote_cache
# SSH SETTINGS
set :user , "rails"
set :deploy_to, "/home/rails/#{application}"
set :shared_directory, "#{deploy_to}/shared"
set :use_sudo, false
set :group_writable, false
default_run_options[:pty] = true
# ROLES
role :app, ip_address
role :web, ip_address
role :db, ip_address, :primary => true
# HOOKS
after 'deploy:setup', 'db:setup'
after 'deploy:update_code' do
db.symlink
assets.symlink
end
121. Cucumber
Feature: Authenticate
In order to see my previous links
As a user
I want to be able to create an account
Scenario: Creating a new account
Given I am not authenticated
When I go to register
And I fill in the following:
| Email | testing@man.net |
| Password | 123456 |
| Password confirmation | 123456 |
And I press "Sign up"
Then I should see "You have signed up successfully"
http://github.com/danielvlopes/buggy/blob/master/features/authenticate.feature
122. feature "Catalog", %q{ Steak
In order to display a catalog in devices
As registered publisher
I want to manage a catalog.
} do
background do
ensure_not_logged_in
@owner = Factory :app, :name => "1Password"
end
scenario "Create catalog for 1Password", :js => true do
visit new_catalog_page_for(@owner)
select "shelf/metal", :from => "Theme"
fill_in "Title", :with => "Appextras"
drag_to_catalog available_app
click "Create Catalog"
should_have_notice "Catalog was successfully created."
end
123. describe Guest
before do
do
Minispec
@room = Room.new("Room 35", Type::Master.new)
@hosting = Hosting.new(@room, 5)
@guest = Guest.new("Daniel Lopes", @hosting)
end
it "should have a name" do
assert_equal "Daniel Lopes", @guest.name
end
describe "when print the invoice" do
it "should have the guest name" do
assert_match /Daniel Lopes/, @guest.invoice
end
it "should have the room name" do
assert_match /Room 35/, @guest.invoice
end
it "should have the total amount" do
assert_match /Valor total: 1000/, @guest.invoice
end
it "should have the discount points earned with that hosting" do
assert_match /Você ganhou 6 ponto(s)/, @guest.invoice
end
end
end
142. Friendster foi escrito em Java e
mudaram para PHP.
MySpace foi escrito em ColdFusion e
mudaram ASP.NET.
Quando as pessoas caem em problemas
de escalabilidade, normalmente acham
que a linguagem é o problema, mas eu
acho que isso raramente é a realidade.
http://www.akitaonrails.com/2008/6/17/chatting-with-
blaine-cook-twitter
143. “O The New York Times usou Ruby on Rails para agregar,
analizar e mostrar os resultados das eleições em quase tempo
real em um de seus sites mais acessados de todos os
tempos.”
http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1