Answer: Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

Answer: Metaprogramming is the writing of computer programs with the ability to treat programs as their data. It means that a program could be designed to read, generate, analyse or transform other programs, and even modify itself while running.

In the example below, here are some of the "meta" changes we're making to the program:

Metaprogramming is supported across many languages using many different techniques; you’ve probably used some of them already. Here’s a brief list of some popular languages besides Ruby that support metaprogramming in some form.

Ruby Class Variables: Class variables begin with @@ and must be initialized before they can be used in method definitions.

Ruby Local Variables: Local variables begin with a lowercase letter or _. The scope of a local variable ranges from class, module, def, or do to the corresponding end or from a block's opening brace to its close brace {}.

Ruby Constants: Constants begin with an uppercase letter. Constants defined within a class or module can be accessed from within that class or module, and those defined outside a class or module can be accessed globally.

Answer: The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass and ERB. The asset pipeline is technically no longer a core feature of Rails 4, it has been extracted out of the framework into the sprockets-rails gem.

Answer: Agile methodology is an alternative to traditional project management, typically used in software development. It helps teams respond to unpredictability through incremental, iterative work cadences, known as sprints. Agile methodologies are an alternative to waterfall, or traditional sequential development.

Answer: Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan. According to its creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, and Lisp. Ruby is "an interpreted scripting language for quick and easy object-oriented programming"

Each gem has a name, version, and platform. For example, the rake gem has a 0.8.7 version (from May, 2009). Rake’s platform is ruby, which means it works on any platform Ruby runs on.

Platforms are based on the CPU architecture, operating system type and sometimes the operating system version. Examples include “x86-mingw32” or “java”. The platform indicates the gem only works with a ruby built for the same platform. RubyGems will automatically download the correct version for your platform. See gem help platform for full details.

Inside a gems are the following components:

Code (including tests and supporting utilities)

Documentation

gemspec

Each gem follows the same standard structure of code organization:

% tree freewill

freewill/

├── bin/

│ └── freewill

├── lib/

│ └── freewill.rb

├── test/

│ └── test_freewill.rb

├── README

├── Rakefile

└── freewill.gemspec

Here, you can see the major components of a gem:

The lib directory contains the code for the gem

The test or spec directory contains tests, depending on which test framework the developer uses

A gem usually has a Rakefile, which the rake program uses to automate tests, generate code, and perform other tasks.

This gem also includes an executable file in the bin directory, which will be loaded into the user’s PATH when the gem is installed.

Documentation is usually included in the README and inline with the code. When you install a gem, documentation is generated automatically for you. Most gems include RDoc documentation, but some use YARD docs instead.

The final piece is the gemspec, which contains information about the gem. The gem’s files, test information, platform, version number and more are all laid out here along with the author’s email and name.

During the normal operation of a Rails application, objects may be created, updated, and destroyed. Active Record provides hooks into this object life cycle so that you can control your application and its data.

Callbacks allow you to trigger logic before or after an alteration of an object's state.

2 Callbacks Overview

Callbacks are methods that get called at certain moments of an object's life cycle. With callbacks it is possible to write code that will run whenever an Active Record object is created, saved, updated, deleted, validated, or loaded from the database.

Answer: Filters enable controllers to run shared pre- and post-processing code for its actions. These filters can be used to do authentication, caching, or auditing before the intended action is performed. Or to do localization or output compression after the action has been performed. Filters have access to the request, response, and all the instance variables set by other filters in the chain or by the action (in the case of after filters).

before_filter

after_filter

around_filter: Around filters wrap an action, executing code both before and after. They may be declared as method references, blocks, or objects responding to filter or to both before and after.

Answer: Using before_filter and after_filter appends the specified filters to the existing chain. That‘s usually just fine, but some times you care more about the order in which the filters are executed. When that‘s the case, you can use prepend_before_filter and prepend_after_filter. Filters added by these methods will be put at the beginning of their respective chain and executed before the rest. For example:

Answer: Engines can be considered miniature applications that provide functionality to their host applications. A Rails application is actually just a "supercharged" engine, with the Rails::Application class inheriting a lot of its behavior from Rails::Engine.