YouTube Icon

Interview Questions.

Top 15 Ruby On Rails Interview Questions and answers - May 05, 2022

fluid

Top 15 Ruby On Rails Interview Questions and answers

Q1. What Do You Mean By Render And Redirect_to?
render makes rails create a reaction whose content is given by delivering one of your formats. Implies, it will coordinate goes to see page.

redirect_to creates a reaction that, rather than conveying content to the program, simply advises it to demand another url. Implies it first checks activities in regulator and afterward goes to see page.

Q2. What Is The Difference Between Delete And Destroy ?
The erase technique basically erases a column (or a variety of lines) from the data set. Obliterate then again takes into consideration a couple of additional choices. In the first place, it will check any callbacks, for example, before_delete, or any conditions that we indicate in our model. Then, it will keep the article that just got erased in memory; this permits us to leave a message offering something like " 'Object_name' has been erased." Lastly, and in particular, it will likewise erase any youngster objects related with that item!

Q3. What Is A Proc ?
Everybody for the most part mistakes procs for blocks, yet the most grounded rubyist can grok the genuine significance of the inquiry.

Basically, Procs are unknown techniques (or anonymous capacities) containing code. They can be set inside a variable and passed around like some other article or scalar worth. They are made by Proc.new, lambda, and squares (summoned by the yield catchphrase).

Blocks are extremely convenient and linguistically basic, but we might need to have a wide range of squares available to us and use them on various occasions. In that capacity, passing a similar square over and over would expect us to rehash the same thing. Notwithstanding, as Ruby is completely object-arranged, this can be dealt with very neatly by saving reusable code as an item itself. This reusable code is called aProc (short for strategy). The main distinction among blocks and Procs is that a square is a Proc that can't be saved, and thusly, is a one time use arrangement.

Q4. Render Vs. Redirect_to In Ruby On Rails ?
render will deliver a specific view utilizing the occurrence factors accessible in the activity.

For instance assuming that a render was utilized for the new activity, when a client goes to/new, the new activity in the regulator is called, occurrence factors are made and afterward passed to the new view. Rails makes the html for that view and gets it once again to the client's program. This is the very thing you would consider a typical page load.

redirect_to will send a divert to the client's program telling it to re-demand another URL as 302 divert reaction. Then, at that point, the program will send another solicitation to that URL and it will go through the activity for that URL, neglectful of the way that it was diverted to. None of the factors made in the activity that caused the divert will be accessible to the diverted view. This happens when you click on 'Make' in a structure and the article is made and you're diverted to the alter view for that item.

Q5. How To Use Two Databases Into A Single Application?
enchantment multi-associations permits you to compose your model once, and use them for the various rails data sets simultaneously.

sudo diamond introduce magic_multi_connection. In the wake of introducing this pearl, simply add this line at lower part of your environment.rb require "magic_multi_connection"

Q6. What Is The Log That Has To Seen To Check For An Error In Ruby Rails?
Rails will report blunders from Apache in log/apache.log and mistakes from the ruby code in log/development.log. Assuming you having an issue, do view what these log are talking about.

Q7. How You Run Your Rails Application Without Creating Databases?
You can run your application by uncommenting the line in environment.rb

  path=> rootpath conf/environment.rb config.frameworks-=[action_web_service,:action_mailer,:active_record
Q8. What Is The Flash?
The glimmer is an extraordinary piece of the meeting which is cleared with each solicitation. This implies that values put away there might be accessible in the following solicitation, which is helpful for putting away mistake messages and so forth. It is gotten to similarly as the meeting, similar to a hash.

streak is an object of Actiondispatch class.

Q9. What Are The Different Components Of Rails ?
The parts utilized in Rails are as per the following:

Activity Controller: the part deals with any remaining regulators and cycle the approaching solicitation to the Rails application.

It separates the boundaries and dispatches the reaction when an activity is performed on the application.

It offers types of assistance like meeting the executives, format delivering and divert the board.
Activity View: it deals with the perspectives on the Rails application and it makes the result in both HTML and XML design.

It likewise gives the administration of the layouts and gives the AJAX support that is being utilized with the application.

Dynamic Record: It gives the base stage to the models and gets utilized in the Rails application. It gives the data set freedom, CRUID usefulness, search capacity and setting the connection between various models.

Activity Mailer: It is a structure that gives email administrations to construct the stage on which adaptable layouts can be carried out.

Q10. What Are The Various Changes Between The Rails Version 2 And 3?
Presentation of bundler (better approach to deal with your diamond conditions)
Gemfile and Gemfile.lock (where all your jewel conditions lies, rather than environment.rb)
HTML5 support
Q11. What Is Agile Development? What Are The Strengths?
Deft programming improvement alludes to a gathering of programming advancement philosophies in light of iterative turn of events, where necessities and arrangements develop through coordinated effort between self-sorting out cross-utilitarian groups

Benefits:

Consumer loyalty by fast, constant conveyance of valuable programming Working programming is conveyed often (weeks instead of months) Projects are worked around persuaded people, who ought to be confided in Continuous regard for specialized greatness and great plan

Effortlessness
Self-coordinating groups
Customary transformation to changing conditions

Q12. What Is A Ruby Singleton Method ?
A strategy which has a place with a solitary article as opposed to a whole class and different items.

Prior to making sense of about singleton strategies I might want to give a little presentation about class techniques.

Class strategy: When you compose your own class techniques you do as such by introducing the technique name with the name of the class.

There are three methods for composing a class strategy.

The principal way is to introduce the class name with the technique name(ClassMethods.method1).
The subsequent way is to introduce the self catchphrase with the technique name(self.method2).
The third way is composing a sepetare class inside the class which contains the strategies (class << self).
Q13. What Is The Difference Between Symbol And String ?
The image in Ruby on rails act the same way as the string yet the thing that matters is in their ways of behaving that are inverse to one another.

The distinction stays in the object_id, memory and cycle time for the two of them when utilized together at one time.

Strings are considered as changeable articles. While, images, has a place with the classification ofimmutable.
Strings objects are impermanent with the goal that it takes just the tasks to change the item data. While, data of, unchanging articles gets overwritten.

-It are composed like to String objects

"string object jack".object_id #=>2250 or
"string object jack".to_sym.object_id #=> 2260, and
"string object jack". to_s_object_id #=> 2270
Images are utilized to show the qualities for the activities like uniformity or non-balance to test the images quicker then the string values.

Q14. Get And Post Method?
GET is fundamentally for simply getting (recovering) information, while POST might include anything, such as putting away or refreshing information, or requesting an item, or sending E-mail.

Q15. What Are Helpers And How To Use Helpers In Ror?
Assistants are modules that give techniques which are naturally usable in your view. They give easy routes to ordinarily utilized show code and a way for you to keep the programming out of your perspectives. The reason for an assistant is to improve on the view.




CFG