Athens
Ruby
Meetup
#4
Rails 3:
Derailing
Rails
Panagiotis Papadopoulos
@panosjee
http://6pna.com
Merb and Rails merge announced on December 23
2008
The hell freezed
High Expectations
Two and a half years later the merge...
Many people accused Rails of
being spaghetti code
Not any more...
Django infuelnces...
Less monkey patching.
The code is well organized and
modular.
You can reuse the components
you want, add yours and create
...
Rails 3 is a top Rack citizen. You can mount any Rack or
even Sinatra in your app.
It is as simple as that:
Store::Applica...
New Responders, less verbose
def new
@product = Product.new
respond_with @product
end
Redirect shortcuts
redirect_to @prod...
No more gem.config in environment.rb
Anyway all this code is moved to application.rb
But your gem dependencies now live in...
Forget script, say hello to rails
New Generators and Commands
Generators help you create *YOUR* convetions
The new ActionMailer is descentant of ActionController so
you no longer have to mixin your models and mailers.
class UserM...
Everything is escaped by default. Use <%=raw %> if
you want markup in your views.
First of all Rails 3 is not tight to Pro...
ActiveRecord inherits from ActiveModel
You can use ActiveModel to build your own ORM
compatible with Rails
Query language ...
An awesome way to extend Rails apps!
Build plugins in no time!
Source: http://www.igvita.com/2010/08/04/rails-3-internals-...
Rails 3 bring
more options to
developers and
a better API to
build upon.
You still have
the Golden Path
or the Rails
defau...
Upcoming SlideShare
Loading in...5
×

Derailing rails

690

Published on

My presenation at Athens Ruby Meetup #4

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
690
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Derailing rails

  1. 1. Athens Ruby Meetup #4 Rails 3: Derailing Rails Panagiotis Papadopoulos @panosjee http://6pna.com
  2. 2. Merb and Rails merge announced on December 23 2008 The hell freezed High Expectations Two and a half years later the merge is complete A lot of new committers Significant efforts by the Merb creator Yehuda Katz Lots of rewrites A new beast New tricks to learn More power to developers Less opinionated thus derailed but still using strong conventions Less monkey patching (oh yes) The story after Rails 3
  3. 3. Many people accused Rails of being spaghetti code
  4. 4. Not any more... Django infuelnces...
  5. 5. Less monkey patching. The code is well organized and modular. You can reuse the components you want, add yours and create the Rails you want, ala carte * you can always monkey patch, do not worry!
  6. 6. Rails 3 is a top Rack citizen. You can mount any Rack or even Sinatra in your app. It is as simple as that: Store::Application.routes.draw do |map| root :to => proc { |env| [200, {}, ["Welcome"]] } end Or if you want a custom controller: In your routes.rb match "/processes" => ProcessesApp In lib/process_app.rb class ProcessesApp < ActionController::Metal include ActionController::Rendering Pure Rack Goodness
  7. 7. New Responders, less verbose def new @product = Product.new respond_with @product end Redirect shortcuts redirect_to @product, : notice => "Successfully created Permanent Cookies Custom responeders No more Metal, you can create your own controllers Controllers in Rails 3
  8. 8. No more gem.config in environment.rb Anyway all this code is moved to application.rb But your gem dependencies now live in Gemfile Bundler is the new way to solve the dependency hell problem. Bundler locks all used gems so when you clone the project you get the same exactly gems and dependencies # Edit this Gemfile to bundle your application's dependencies. source 'http://gemcutter.org' gem "rails", "3.0.0.beta" # ActiveRecord requires a database adapter. By default, # Rails has selected sqlite3. gem "sqlite3-ruby", :require => "sqlite3" Gem dependecies. Bundler.
  9. 9. Forget script, say hello to rails New Generators and Commands Generators help you create *YOUR* convetions
  10. 10. The new ActionMailer is descentant of ActionController so you no longer have to mixin your models and mailers. class UserMailer < ActionMailer::Base default :from => "eifion@asciicasts.com" def registration_confirmation(user) mail(:to => user.email, :subject => "Registered") end end A new ActionMailer! At last!
  11. 11. Everything is escaped by default. Use <%=raw %> if you want markup in your views. First of all Rails 3 is not tight to Prototype. It is still the default but you can use easily any major Javascript library. All helpers produce UJS code In your views: <%= link_to "Destroy", @product, :confirm => "Are you sure?", :method => :delete %> Produces the following html code: <a href="/products/8" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a> Unobtrusive JS using HTML5, XSS Security
  12. 12. ActiveRecord inherits from ActiveModel You can use ActiveModel to build your own ORM compatible with Rails Query language is now AReL Chain everything! More details by Savvas ActiveRecord
  13. 13. An awesome way to extend Rails apps! Build plugins in no time! Source: http://www.igvita.com/2010/08/04/rails-3-internals-railtie-creating-plugins/ Railties
  14. 14. Rails 3 bring more options to developers and a better API to build upon. You still have the Golden Path or the Rails defaults but you face less restrictions on how to build stuff Huge performance gains You better start off with Ruby 1.9 using RVM so that you migrate to the new Ruby stack Be careful with your gem and plugins selections, things are a bit... edgy Tested against other major VMs such as Ruby 1.8, 1.9, JRuby, Rubinious Thank You! @panosjee
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×