Master Ruby on Rails - SkillBakery Studios

Breaking

Post Top Ad

Post Top Ad

Sunday, May 31, 2020

Master Ruby on Rails


                                        Master Ruby on Rails




We live in a high technology era, where development speed is increasing day by day and as a developer, we need new skill sets that will help us to build this web development era. Here we are choosing Ruby on Rails which helps us develop custom web applications. Learning a new language will help you grow as a developer and an asset to your company. If you are already working on this, this will give you a quick recap.

What is Ruby?
Ruby is a dynamic object-oriented language in which everything is an object. It is easily readable because of easy syntax and behavior. It is considered as a great language for web development.

Rails are actually very easy for beginners even for those who never code not only rails but the language Ruby it’s built on as well.

As we know Ruby on Rails is an object-oriented language that makes development less complex, unlike other languages that work or function by giving a set of tasks to execute. It creates virtual objects. Each object has its attributes and can easily interact with other objects to perform actions. It is not complex and objects created can be easily reused in other programs.

Let us walk through some of the guiding principles which make ruby on rails a better choice

Guiding Principles to work on Ruby
There are some guiding principles which make use of ruby on rails a better choice for web development

Don’t repeat yourself (DRY) in this every single piece of information must have a single and relevant representation within the system .it reduces the information to be repetitive. This aim is to reduce code repetition so that it becomes easy for a developer to make any modification in the development life cycle.

Convention over Configuration, it’s a development principle which aims to reduce time and efforts taken by the developers for e.g. if there is a class called “student” the relevant table in the database will automatically name as “students”.


Model View Controller
Model View Controller (MVC) the architecture separates application-data, control, logic, and user interface all together on a different level.MVC separates the application into different components.




In fig: When we interact with the application web browser sends a request which a web server receives and passes onto the router, router redirects to the related controller. The controller renders the view to the web browser and a complete web page is returned to the user’s browser.

Active Record Pattern
Active Record is to handle database communication and business logic.it helps establish a connection to the server. It ensures data access logic as a part of the object and helps users of that object to read and write data from the database.

To follow all these you need to install by following the given video link



Once we are done with the installation we can create rails projects, rails give us boilerplate code. This code can be included in many places with minimum alteration.
Why we use boilerplate code?
Early Development –It reduces the software development time by reusing core things
Less Complex- gives you possible cleaner code.

Creating your first application using ruby on rails
To start with we need the following.
Text Editor – you can use any text editor
Browser – here we are using Ubuntu default browser

Steps to follow
Step 1.
Create directory hello in which all the code is already present and we can navigate through the command line
mkdir  hello-- Make a directory

Step 2.
Change the directory to  hello
Cd hello– change directory
Step 3.
Create a new application with the name helloworld
rails new helloworld


Output :


File and Folders
Description
app/
Contains the controllers, models, views, helpers, mailers, channels, jobs, and assets for your application
bin/
Contains the rails script which starts your application and can contain other scripts you use to set up, update, or run your application.
config/
Configure your application's routes and database.
config.ru
Rack the configuration is used to start the application.
Gemfile
Gemfile.lock
These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem.
Rakefile
This file locates and loads tasks that can be run from the command line. Rather than changing Rakefile, we can add our own tasks by adding files to the lib/tasks directory of your application.
README.md
This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on.

.gitignore
This file tells git which files (or patterns) it should ignore.

Now that you already have a functional Rails application. To see it, you need to start a web server on your development machine. You can do this by running the following in the blog directory:

 $ rails server

If you are using Windows, you have to pass the scripts under the bin folder directly to the Ruby interpreter
ruby bin\rails server.

To see your application, open a browser, and navigate to http://localhost:3000.
You should see the Rails default information page:



By now we learn how to start with ruby. Now, let’s see some features and benefits while using ruby on rails.

Features of Ruby on Rails
Action view – In Rails, all the web request is handled by action controller and Action View controller is responsible for communicating with the database.
Action cable – It is a built-in library on both server-side and client-side it pushes through web sockets.
Render from anywhere – In the latest version of Rail 5, we can render view from anywhere. Previously we were using the gem to render views outside the controller.
AJAX library – Rails gives you access to the full library of AJAX functions scripting is generated.
Symbol garbage collection – Symbols which we create when not referenced with any object or variable, we can safely collect them with a symbol garbage collector
Migration Engine – Migrations are a way to alter the database schema. Each migration is a new version of the database.

Benefits of Ruby on Rails

Libraries – There is a 3rd party module gem. They are publically available and searchable through.
Quality of code – Code quality is significantly higher than other languages or frameworks.
Largest Community- It is very popular among coders all over the world.
Productivity – As it uses 3rd party libraries so it easily enables the development features.

Including features and benefits we can say rails is packed with features that make developers more productive and to learn in a more fun and engaging way kindly visit our youtube channel



And to go for detailed course packed with live examples kindly visit 





 


                                    

No comments:

Post a Comment

Post Top Ad