Joshua Muheim
Joshua Muheim

Reputation: 13195

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.

Upvotes: 1

Views: 182

Answers (1)

Charles Stevens
Charles Stevens

Reputation: 1584

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).

Upvotes: 2

Related Questions