27. RSpec
describe Product do
include ProductSpecHelper
before(:each) do
@product = Product.new
end
it quot;should not be valid when emptyquot; do
@product.should_not be_valid
end
it quot;should be valid when having correct informationquot; do
@product.attributes = valid_product_attributes
@product.should be_valid
end
end
Tuesday, January 20, 2009
28. RSpec
describe Product do
include ProductSpecHelper
before(:each) do
@product = Product.new
end
it quot;should not be valid when emptyquot; do
rake spec
@product.should_not be_valid
end
it quot;should be valid when having correct informationquot; do
@product.attributes = valid_product_attributes
@product.should be_valid
end
end
Tuesday, January 20, 2009
35. Rotas RESTFul
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/service.wsdl', :action => 'wsdl'
map.resources :products,
:member => {:change_image => :post}
map.resources :addresses
map.resources :orders,
:has_many => [:line_items]
map.namespace :admin do |admin|
admin.resources :users
admin.resources :products
end
end
Tuesday, January 20, 2009
36. Rotas RESTFul
ActionController::Routing::Routes.draw do |map|
GET /products/new
map.connect ':controller/service.wsdl', :action => 'wsdl'
GET /products
map.resources :products,
:member => POST /products
{:change_image => :post}
map.resources :addresses
GET /products/1
map.resources :orders,
GET /products/1/edit
:has_many => [:line_items]
map.namespacePUT /products/1
:admin do |admin|
DESTROY /products/1
admin.resources :users
admin.resources :products
end
end
Tuesday, January 20, 2009
37. Migrations
class RenameAppConfiguration < ActiveRecord::Migration
def self.up
rename_table :app_configurations, :configurations
change_table :configurations do |t|
t.string :type
end
end
def self.down
change_table :configurations do |t|
t.remove :type
end
rename_table :configurations, :app_configurations
end
end
Tuesday, January 20, 2009
38. Migrations
class RenameAppConfiguration < ActiveRecord::Migration
def self.up
rename_table :app_configurations, :configurations
change_table :configurations do |t|
t.string :type
end
rake db:migrate
end
def self.down
change_table :configurations do |t|
t.remove :type
end
rename_table :configurations, :app_configurations
end
end
Tuesday, January 20, 2009
42. Tuesday, January 20, 2009
http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming
http://weblog.jamisbuck.org/2008/11/29/recovering-from-enterprise-video-available
43. 11 mil
classes!
46 só de
Collections!
Tuesday, January 20, 2009
http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming
http://weblog.jamisbuck.org/2008/11/29/recovering-from-enterprise-video-available
44. • Classes:
• Modules: • Array
• Enumerable • Hash
• Comparable • Set
• Sorted Set
Tuesday, January 20, 2009
45. 1.400 Classes:
•
classesArray
• Modules: •
• Enumerable • Hash
• Comparable 6 de Set
só •
• Sorted
Collections! Set
Tuesday, January 20, 2009
46. • Convention over Configuration
• Don’t Repeat Yourself
• You Ain’t Gonna Need It
• Automação
• Boas Práticas
• Código Bonito
• Ferramentas Simples
Tuesday, January 20, 2009
62. Tuesday, January 20, 2009
FUD: http://www.techcrunch.com/2008/05/22/twitter-at-scale-will-it-work/
63. To put things into
perspective, though,
Friendster was written in
Java to start, and switched to
PHP. Myspace was written in
ColdFusion and transitioned
to ASP.NET.
When people run into
problems scaling sites they
often think that the language
is the problem, but I think
Blaine Cook
it’s rarely the case.
http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter
Tuesday, January 20, 2009
http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter
64. “The New York Times used Ruby on Rails to pull
together, analyze and display election results in
near real time on one of its busiest Web
traffic days ever. ”
http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1
Tuesday, January 20, 2009
http://www.computerworld.com/action/article.do?
command=viewArticleBasic&articleId=9120778
65. “They serve up 23 million visitors a month. The conversion resulted in 20,000
lines of Ruby code instead of 125,000 lines of Java code, and most importantly
eased the difficulty they had in maintaining it. Once complete, and
optimized their site is now faster than before. They also completed the
rewrite in three months with four developers.”
http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails
Tuesday, January 20, 2009
http://www.akitaonrails.com/2008/11/21/rails-podcast-brasil-qcon-
special-john-straw-yellowpages-com-and-matt-aimonetti-merb
http://www.rubyonrailsexamples.com/sites-on-rails/yellowpagescom-
goes-ror/
66. Tuesday, January 20, 2009
http://www.techcrunch.com/2008/01/24/hulu-discusses-private-beta-
suggests-public-launch-time-frame/