Merb vs Ruby on Rails

From WikiVS, the open comparison website
Jump to: navigation, search
Merb Ruby on Rails
Ruby on Rails

Merb and Ruby on Rails are MVC web application frameworks written in and for Ruby. Both have similar directory structures and concepts. Ruby on Rails (RoR) is more featured while Merb aims to be simpler and more modular. Merb and RoR are merging development efforts and will be one product for Merbv2/RoRv3


Rails is focused on rapid development for the web programmer. This means that oft-requested features and helpers are included in Rails itself or in a plugin. Also, this means that Rails comes configured in "the Rails way," which emphasizes convention. Because Rails comes bundled with so many tools and functions, the web programmer can focus more on business logic and design rather than on how to implement the logic and the design.

Merb is focused on speed and extensibility. These two factors are the most complained about "problems" with Ruby on Rails. Users who would want a faster, leaner server should go for Merb since less time is spent inside the framework stack and more in the users' code. Merb, although similar in structure to Rails, provides less of the helpers in its core (called merb-core). Merb-core only includes the basic necessities for building an MVC web server. In fact, it doesn't even come with an ORM for the "M" in "MVC."


Merb intentionally is lighter than Rails and thus is faster. Faster means that processing time is spent less inside framework code and more inside the users' own code; users' own code is still executed at the same speed, except currently Merb also uses a faster Ruby re-implementation Erubis over the original and slower ERB.


Rails is at version 2.2.2 and is very stable. There are currently many production servers using Rails. Not as many use Merb for production servers. Merb is in version 1.0.


Both Merb and Rails support plugins. Although the plugin structure is different for Merb and Rails, Merb can also use Rails plugins where applicable.

Rails includes more features and helpers in its core, while Merb separates all non-basic functionality into merb-more.

Like Ruby on Rails, Merb is an MVC framework. Unlike Rails, Merb is ORM-agnostic, JavaScript library agnostic, and template language agnostic, preferring plugins that add in support for a particular feature rather than trying to produce a monolithic library with everything in the core. In fact, this is a guiding principle of the project, which has led to third-party support for the ActiveRecord, DataMapper, and Sequel ORMs.


Action Ruby on Rails Merb
Create new application 'app1' rails new app1 merb-gen app app1
Start server rails server merb
Start cluster of 3 beginning at port 3000 N/A merb -p 3000 -c 3
Interactive console rails console merb -i

File Organization[edit]

Action Ruby on Rails Merb
Routes configuration config/routes.rb config/router.rb
Server configuration (host, port, authentication, etc.) config/environment.rb config/merb.yml
Initialization code config/environment.rb & config/initializers/* config/init.rb
Dependencies (load path, plugins) config/environment.rb config/dependencies.rb
Plugins vendor/plugins gems
Migrations db/migrate schema/migrations
Testing test spec & test
Public public public
Models app/models app/models
Controllers app/controllers app/controllers
Views app/views app/views
Helpers app/helpers app/helpers
Custom Libraries lib lib