Rails 3: Organic Unicorn Whispers
Ladies and gentleman, I’m about to jack you up with some tasty treats. Thats right, prepare to get hit in the face with a fist of refreshing merriment. You think this is a joke? Cause I’m not laughing…
Rails 3.. This bundle of delight is sure to put a smile on your ugly ass. So scrumptious in fact, after reading this blog post you’re probably going to do one of two things.
• frolic through the sunkissed meadow blowing dandelion petals
• feed splashing narwhals sardines out of you smiling mouth
Thats the kind of elation you’ll get when you bear witness to what Rails 3 pony’s up. Pretty much on par with organic unicorn whispers.
Lets begin this exaltation with our rapture from dependency hell. Meet my new best friend bundler. 1.) Specify your gems in a Gemfile 2.) Run “bundle install” 3.) Profit.. Need to lock down your gems? “bundle lock” I’ll let you marinate on that for a second…
Scope this player..
class Post < ActiveRecord::Base
scope :published, lambda {
where("posts.published_at <= ?", Time.zone.now)
}
scope :published_since, lambda { |ago|
published.where("posts.published_at >= ?", ago)
}
scope :recent, published.order("posts.published_at DESC")
end
Stop drooling all over your keyboard for a second there chief and reflect on the allure of these refactored scoping methods. Ahhh, yes..
Moving on, stay with me..
No more pouting over routing. Rails 3 sprinked nectar all over routing’s face. Basically, more minimalist, succinct, powerful, flexible, sexy routing. e.g.
# Rails 3
root :to => 'forthe#win'
# Rails 2
map.root :controller => "forthe", :action => 'win'
# Rails 3
resources :products do
resource :category
member do
post :short
end
collection do
get :long
end
end
# Rails 2
map.resources :products, :member => {:short => :post}, :collection => {:long => :get} do |products|
products.resource :category
end
Still want more, fine.. How about agnosticism? Use whatever ORM you like. Use whatever javascript library your pretty little head desires. Rails 3 won’t judge you.
Well cupcake, so ends another spectacularly humorless blog post.. Hopefully you’re not nauseated by my writing and are becoming elated to begin working with Rails 3.
21/07/2010 at 11:43 pm Permalink
APIs codec LDAP/SAML conversions MP4 redmine.
22/07/2010 at 6:41 am Permalink
Man, this shit is dope sick son…