Is Rails 3 modular like Merb and Ramaze - ruby-on-rails

Will Rails 3 be a modular framework like Merb or Ramaze?
By this I mean, can we use any persistence framework (DataMapper or Sequel) and jQuery in Rails 3 application (via the command line for example)?
Or the default stack (ActiveRecord, Prototype) is still enforced?
(Sorry, I'm pretty new to Ruby/Rails community).
Thanks.

Rails 3 is much more modular than previous versions. Although it still defaults to ActiveRecord and Prototype, it has an ActiveModel API which means that ActiveRecord can be swapped out for a compatible ORM that implements the API.
Rails 3 also embraces the principles of Unobtrusive JavaScript and to this end the view helpers no longer output inline JavaScript mixed up with HTML. Instead, HTML5 data attributes are used and there are Prototype and jQuery "drivers" for hooking into those and adding behaviour to elements.
The whole ActionController stack is also much more modular enabling you to cherry pick just the parts you need and the common (non-HTTP specific) controller functionality is now shared by ActionMailer too.

Rails merged with Merb in late 2008 and the result is Rails 3
http://yehudakatz.com/2008/12/23/rails-and-merb-merge/
http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3

Related

if defined?(ActionController) and defined?(ActionController::Base)

Its a code snippet from act_as_audited plugin 1.1.1 under rails/init.rb
Why is this code used? Any general explanation of it is welcomed.
if defined?(ActionController) and defined?(ActionController::Base)
acts_as_audited is intended to be usable with plain ActiveRecord. As you can use ActiveRecord outside of Rails, e.g. in a Sinatra app, it is helpful if a gem doesn't tie itself to Rails.
This is exactly what is happening here: the authors try to detect if they are running under Rails (or more specifically, if the app uses ActionController for routing which is part of Rails) to load additional Rails-specific functionality.
For apps not using ActionController (or Rails), the gem is thus still usable.
It seems that they have dropped this compatibility layer in later releases. This, the successor of acts_as_audited (called just audited) depends on Rails now.

Ruby On Rails: of what main components (gems) does it consist?

I'd love to dive deeper into Ruby On Rails so I can understand the magics behind it.
For this, I'd like to examine all main components (gems) of Rails one by one, e.g. ActionPack, ActiveResource, etc. For this I'd love to have a list with the main components with short explanations (I will add more explanations step by step when learning about the gems).
Feel free to edit my answer with supplementary details.
Following are the Basic rail components with their short discription::
Active Support is a compatibility library including methods that aren't necessarily specific to Rails. You'll see ActiveSupport used by non-Rails libraries because it contains such a lot of useful baseline functionality. ActiveSupport includes methods like how Rails changes words from single to plural, or CamelCase to snake_case. It also includes significantly better time and date support than the Ruby standard library.
Active Model hooks into features of your models that aren't really about the database - for instance, if you want a URL for a given model, ActiveModel helps you there. It's a thin wrapper around many different ActiveModel implementations to tell Rails how to use them. Most commonly, ActiveModel implementations are ORMs (see ActiveRecord, below), but they can also use non-relational storage like MongoDB, Redis, Memcached or even just local machine memory.
Active Record is an Object-Relational Mapper (ORM). That means that it maps between Ruby objects and tables in a SQL database. When you query from or write to the SQL 19database in Rails, you do it through ActiveRecord.
ActiveRecord also implements ActiveModel. ActiveRecord supports MySQL and SQLite, plus JDBC, Oracle, PostgreSQL and many others.
Action Pack does routing - the mapping of an incoming URL to a controller and action in Rails. It also sets up your controllers and views, and shepherds a request through its controller action and then through rendering the view. For some of it, ActionPack uses Rack. The template rendering itself is done through an external gem like Erubis for .erb templates, or Haml for .haml templates. ActionPack also handles action- or view-centered functionality like view caching.
Action Mailer is used to send out email, especially email based on templates. It works a lot like you'd hope Rails email would, with controllers, actions and "views" - which for email are text- based templates, not regular web-page templates.
Action View is a framework for handling view template lookup and rendering, and provides view helpers that assist when building HTML forms, Atom feeds and more. Template formats that Action View handles are ERB (embedded Ruby, typically used to inline short Ruby snippets inside HTML), and XML Builder.
Action Resource (ARes) connects business objects and Representational State Transfer (REST) web services. It implements object-relational mapping for REST web services to provide transparent proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing in ActionController::Resources).

Looking for a fully functional Rails application using Backbone.js

Backbone.js website has some examples. But barring the first one others are not open source. I am looking for a fully functional (meaning it just works) Rails application to study. The app does not need to have too many functionalities. I looked at github and all the apps are broken in some ways.
Recently i found https://github.com/malclocke/fulcrum and it seems to be the best Rails/Backbone example but its not mentioned on the backbone website. Its also a very functional pivotal tracker clone.
I have been working on some non open source projects that use a Rails and Backbone.js stack. Both frameworks can be integrated fairly easily. Of course, it depends on how the application is setup and how you configure each framework to control more or less business logic.
To get both frameworks to play with each other:
Make Backbone collections and models for each Rails model
Route resources for each Rails model
Setup the URL property for the Backbone collections and models to work with your rails routes
Use fetch() and save() in Backbone to get and post data with Rails
I wrote a german language noun trainer using RAILS and backbone.js. It was done a long while ago while I was still learning but you can peek at it if you want.
https://github.com/bradphelan/ohmyderdiedas
I've been actively working on Myelin: http://sourceforge.net/projects/myelin/ (funded from a corporate source)
There are some caveats:
This is essentially a first for me with every technology in there... from rails, to backbone / jquery / rspec... you name it... it's new, so take the code with some grains of salt ;)
I didn't use the Backbone routing, and built a very simple 'router' of my own.
You'll need ganglia and rrdtool installed (macports if you're on a mac should work)
You'll need to alter the development config for sure.
The models, are (mostly) straight up backbone, and I use sync often in the controllers so those should be pretty good examples.
The views are a little more chaotic.
If anyone needs help with anything, just drop a line to me on sourceforge.
There's now a gem in development that provides generators, called rails-backbone. It's Open Source and getting better every day. As of today it's up to date with current Rails 3.1 (actually 3.2 now), esp. including Asset Pipeline, which is very relevant to backbone.js.

Does rails3 provide any hooks for dropping in pluggable, re-usable components?

What efforts have been made in rails 3 to encourage code re-use? Is there anything akin to merb slices / engines built into the framework that would allow me to drop in a configurable component such as a 'blog' engine? If so, what is considered best practice?
On Russian dolls and mountable apps
One of the hottest new features in Rails 3 is the ability to embed a Rails application in another Rails application. This allows the development of components that range from user authentication to a fully featured forum.
See here for more
You can also use Rack with Rails.

What is new in rails 3?

Couldn't find any compiled info on new things in rails 3. Nor release date.
From http://mcphersonz.wordpress.com/2009/05/13/key-features-for-rails-v2-2-rails-v2-3-and-the-upcoming-rails-v3-0/
Lock up all the unicorns. You can’t please everyone all the time, so don’t focus on the unicorns.
No holy cows. Nothing is sacred in rails & everything is up for debate. Don’t look any anything we have & feel like that is the way it has to be.
Major Themes:
New routes. Faster, route by subdomain, user agents, etc. Rack to other rack machinery.
XSS protection (cross side injection). By default all output in views will be escaped. No more use of <%= h something %>. Assumed by default.
Javascript goes Unobtrusive & Agnostic. Much less JS is injected into page & instead unobtrusive JS is used to achieve same effect.
More Agnosticism.
Action ORM is a slim proxy wrapper for ORM tools that allows for easy swapping of ORM implementation,
Generators (script/generator) will for example allow you to specify that rspec is used, so script/generate model will create a rspec test file for model.
Refactoring
Abstract Controller takes similarities between for example ActionController & ActionMailer and combines them into one code base.
Cherry picking from ActiveSupport allowing you to pick parts that are used instead of pulling in the entire library.
Increased performance / speed with callbacks.

Resources