| Welcome to our Ruby on Rails tutorial. This tutorial will cover many areas of the ruby and rails programming language. If you think a part of this tutorial is incorrect please feel free to edit it. In the programming world we have been gifted by several programming languages, and they all have their merits and demerits. Ruby is one of the very efficient and effective programming language and it has been accepted as the programming language which can perform the task in a much smarter and faster way as compared to any other programming language. This language has made programming a simple task for all the programmers as it provides results in a fast manner. The programmers can now very easily see their vision and ideas being transformed directly to the code form. Ruby also works strongly on the basis of Object-Oriented design like C++ or Java. The web application framework which was given by David Heinemeier Hansson was named as ¡° Ruby on Rails¡±. It is designed on various component libraries and works in a similar way as any web application framework. Rails, also like ruby has got world wide acceptance and has successfully been implemented by programmers as one of the efficient development tools. |
| What is Ruby |
Ruby was introduced by Yukihiro Matsumoto (known widely as ¡°Matz¡±) in 1994. Ruby is a very interpreted language which has many strong features of various languages. It is a strong Object oriented programming language which also has single inheritance as in Java. It also provides us with the feature called as mixins. Using mixins we can easily import methods from multiple classes using modules. Ruby also has the scripting feature similar to the Python and Perl. The Object oriented concept from C++ and Java also maintains the reliability of programming in addition to maintaining the security of code. Ruby is open source which means that it is free to be used; one does not need to pay anything to use it. Because of this feature of Ruby it is used worldwide by everyone.
|
| History of Ruby |
Ruby was introduced by Yukihiro Matsumoto (known widely as ¡°Matz¡±) in 1994 and was officially released by Matz in 1995. Rails framework was designed and given by David Heinemeier Hansson in 1994. It was developed under the MIT License system and thus made Ruby on rails an open source and free to be implemented by everyone. This is again an important reason as to why Ruby on Rails has acquired a significant position in programming. |
| Why learn Ruby |
As stated earlier, since Ruby is an open source, and it is free and many people have opted to purchase the license so that they can make it a cross platform language as per their suitability. Ruby can easily recognize the variable types all by itself. Due to this feature coders are not required to define variable types as we have to do in several other programming languages. Not only this, we do not need to declare the variables specially too. Ruby's dynamic typing also saves a lot of typing time of the programmers. Ruby has been provided to programmers with various class libraries which are bundled together. These class libraries start from the basic data types to advanced level thread and network programming. These class libraries have not been saturated yet and Ruby still is in the process of getting more libraries with time to make programming more simple and efficient. Ruby also comes with an effective garbage collector which avoids the problem of memory leaks to a great extent and takes care of th e misuse and unnecessary occupancy of the memory. Ruby provides us with familiar syntaxes which are known to C++,Eiffel, Perl, and Python programmers. These syntaxes are composed of all the common features available for the programming like the comments, identifiers, reserved words, literals, arrays, Regular expressions etc. |
| Ruby and Object-Oriented Programming |
Ruby follows strict concepts of Object Oriented programming languages and thus has objects, methods and classes available for programming. It has all the ways by which we can handle these objects and classes in a smooth manner. Now let¡¯s have a look at a few basic phenomenas which are available in OOPS Ruby is also facilitated by them . The common features of OOPS are Objects, Classes and Instances, methods, Portability, Security. We will talk about these in brief in the section below to have an understanding of the same. Objects are the real world entities. In programming these objects are used to make proper use of all methods which are available in the classes. whenever we want to work on any object, we need to create a new object first, then the initialization of that particular object is done. Classes and Instances: Ruby also has classes and Instances. Objects are nothing but the instances of the Class class.This can well understood as objects are nothing but the mirror copy of the classes with all its attributes and properties. Normally all the instances in programming are made with the help of a new method but here it is advised to have the initialization method to create the objects. The complete data here is confined in the Objects and we work on these objects by implementing the methods available in the particular class. It is a general practice that the Class name should always be a unique name and needs to be a constant as it helps to differentiate one class from the other. Whenever we call any class method in Ruby, it tries to track a particular method at several locations. It also follows a specific path to locate that method so as to avoid wastage of the searching time . Methods: In ruby, all algorithms that we write on any object are placed safely in methods. Method can be defined as code which is given by any class to a object to perform all the series of instructions. The entire code which we write in Ruby is nothing but the method of one or the other object. Many times we feel that ruby provides us the option of creating our own functions in the front but it originally follows the same mechanism at the back of programming. We also have Singleton methods in Ruby. Whenever any particular method has a strict association with a particular and a specific object we call these type of methods as Singleton methods. These methods are defined with the help of def statements. Security: Although Ruby provides the programmer with portability the programmer can keep it's code in a distributed form over the network. The security system of Ruby is robust that the programmer does not need to worry about the authenticity and the safety of its valuable code. The data portability is an important feature of Object Oriented Programming languages. We have a very strong concept of Lock down in ruby which enables the programmer to decide which part of his code or data may be a threat to the remaining part of the code. He can execute it under strict supervision thus saving the danger of getting the remaining data being effected by that set of code. This feature of Ruby has made it a very strong point as to why the programmers have accepted Ruby more than any other programming language when we talk about the security feature. Not only this we can also execute our Ruby programs under the tight security check. This is done by enabling the security check option being turned on. We also have a variable known as $SAFE which helps us to find out the safety level of the code.
|
| What is Rails |
Rails, in its simplest terms can be defined as the framework which constitutes the mix of variety of programmes which perform the task of writing most of the application segment for us thus making our task of programming much simpler and easier to use. Not only this we can always have the flexibility of reusing this framework any number of times as we need to install it once. Then can implement it on n number of applications that we develop. As stated above, since Rails is also a framework it also follows the same pattern as any other programming framework. These frameworks when implemented ease up the task of the programmer as it reduces a large amount of code writing and the programmer needs to specify code which provides the instructions or the guidelines to the framework as to what has to be done.This means that if we are implementing any type of framework in our application we are saving a lot of coding time and also making our applicxation more efficient by reusing the already installed framework. This framework is also designed on the model wherein the entire application is segregated in three different layers: 1. Model 2. View 3. Controller In short we call this model of framework as MVC model and by implementing the MVC model at the time of developing the applications we can have our application been made into three sections where in the first section the Model helps us to analyse and design the database and other administrative tools that are required for that particular application to be developed. The View Section as the term illustrates has everything to do with the look and feel of the application. All the pages which are going to be designed and linked to that application. For example, if we are in process of developing any reservation making application we need to have a welcome page, followed by a registration form filling page, a confirmation page and so on. Thus this section of the model can well be considered to be the backbone of the MVC framework on which Rail works as it determines how the entire application will be visible to the end User. The Controller section of this model determines all the different situations and the instances which needs to be associated with that application and then to be formalized in the application in the form of its functionality. Thus handles the entire control of the application. In a nut shell, we can state that what ever is been done in any Rail application has to be a part of any one of these sections. Nothing in the application goes beyond the scope of the MVC model of this framework.
|
| Why Ruby and Rail together |
Ruby and Rails are mostly been spoken together although they both have their individual existence and can very well go without each other. The reason why they are taken together is that Ruby is the base foundation for Rails and thus it will be fully correct to state that they both carry parent child relationship with each other and thus we can say that Ruby is the parent and Rail is the child. We can work very easily on Rails if we have the knowledge of Ruby as the basic conventions of Rails are similar to conventions of Ruby but that doesn¡¯t mean that we can¡¯t work on Rails if we haven¡¯t worked on Ruby but, yes, the efforts in the programming will definitely increase and also the time taken to make your application go up and live. It helps a lot to understand the code of rails, it's functionality if we have the knowledge of Ruby while working on Rails and thus they both go side by side. Ruby helps a programmer to be a more developer by giving him a better understanding of the code he is working with. It makes programming easier as the developer is familiar of the readily available idioms and conventions of Ruby. Ruby also makes the debugging quite an easy task for the programmer when he is working with Rails. Ruby on Rails, hence can very well be stated to be a very efficient way of developing the successfully running web applications in a very lesser time as compared to the other programming languages and development environments. |
| Garbage Collection |
Ruby has been introduced with a very strong and effective feature called as Garbage Collection. Although this feature is a part of many programming languages but Ruby has made it more efficient as it has the automatic mechanism of finding out and cleaning the garbage and thus freeing the memory automatically. This results in the reduction of the memory leakages. It effectively cleans up the dynamically allocated storage space in the memory and avoids a lot of application crashes.We do not have to release the memory allocation space in Ruby as we have to do in other object oriented programming language like C++. Thus the garbage collector of Ruby does the task of freeing the unused objects automatically, making Ruby more successful in programming languages. In today¡¯s programming era, when the programmers are looking for an environment which will provide them a very productive framework and also the concepts of Object Oriented programming, the best choice is Ruby on Rails. And so Ruby on Rails is the complete package full of features for a wonderful programming experience. |
discuss this topic to forum
