Role of modules and Mix-ins in ruby on rails
Click to rate this post!
[Total: 0 Average: 0]

I hope after reading the title, you will be in uncertainty because the words seem to be some to be somewhat new to you. But the topics were not new to you .these were the old topics which were not new to the developers. Today in this article I would like to share the role of modules and mix-ins in ruby on rails.

Today many developers do a lot of programming. The programming length is un- expectable. But that length code is not unique all the case. There some cases where a certain piece of code being used multiple times.  The reason for being used of the same code in multiple, the same function is being called at multiple places . for example in a code like e-commerce project, the payment gateway must be placed across multiple places. Because in that website, same for every product the user buys, he needs to pay the money and then get the product. So this payment gateway interface code must placed across the multiple products in the website. So in such cases, we need a  programming language concept which allows the feature of writing the code at one place and gives access to multiple places across the project.

Know more on Ruby on rails from OnlineITGuru through Ruby on Rails online Training Hyderabad.

Programming languages likewise Java, Python will give the solution to his problem through its features like polymorphic, Inheritance, Interfaces etc.

Before going to know the role of modules and Mix-ins, let me introduce you those  Oops concepts in detail.

 OOPS, concepts were nothing, but the programming languages which support the features like code re-usability, class extension etc. Let me explain one -by- one in detail.


A class is simply the collection of methods, variables. Here the class name is prefixed with a class Keyword.

Here modules were nothing, but the class with contains a set of variables, methods, functions etc. Each module must be prefixed with the keyword Module

 Syntax:       module A

                  Statements 1 …

                  Statements 2 .Role of modules and Mix-ins in ruby on rails

This Modifier name must start can be any word which starts with a Capital letter. These module methods defined just like the class methods. You can call the module through its name by following its functions names separated by two colons. A require statement usually added to the program in some cases. Because there is no necessity to write the code for all the entire programs. There are cases where there is already predefined code. This predefined is ready to use code. This code can be used in our programs  by using the keyword REQUIRE which is similar to IMPORT statement in JAVARole of modules and Mix-ins in ruby on rails

Now let me take to the next in Role of modules and mix-ins in ruby on rails


It is the phenomenon of calling the methods of a super class by a subclass. The class contains all the code known as a Super class and accesses all these methods defined as a subclass. A subclass extends the super class by using the keyword extends

 Ex: Class A extends C

In the above example, class A called as a parent Class and class C called the subclass. Here class C acquires the all the properties of its superclass under the name class A

But the vice versa does not applicable

This concept is quite similar to the relationship of family members. Usually, we would get the genes of the family members from our elders to us. But not the genes of us to our family members.

Mix-ins are just similar to the concept of applying Inheritance. Through Mix-ins the user has a scope of reusing the code and have the access to the code.

Know more  on Mix-ins from the real time of experts of OnlineITGuru through Ruby on Rails online training

Recommended Audience :

Software developers

Team Lead’s

Project Managers

Database Administrators


Nothing much prerequisites required to purse  Ruby online Course, good to have knowledge of basic Concepts of PHP  And  HTML but it not mandatory. Trainers of Online IT Guru will teach you if you don’t have knowledge of those Concepts.

Drop Us A Query

100% Secure Payments. All major credit & debit cards accepted.

Call Now Button