Interview Questions For Ruby-on-Rails Part - 2


Posted August 1, 2019 by outsources

outsource ecommerce software, web developer freelancers, outsource psd to html, outsource web developer, outsource web developers

 
Have an upcoming Ruby on Rails interview for a Ruby On Rails web developer position?
Experienced developers at Auction Software have gathered together to collaborate on this list of Ruby on Rails interview questions to help you prepare for your Ruby on Rails technical interview. Can you answer them all?
What is metaprogramming?
Ruby developers should know what’s metaprogramming, because it is widely used, especially in popular frameworks such as Rails, Sinatra, and Padrino. By using metaprogramming, we can reduce duplicate code, but there is a downside where it will increase the complexity of the code in the long run.
Here’s an example of metaprogramming in Ruby:
A user can have a lot of roles, and you want to check the authorization.
Explain how Symbol is different from variables?
Symbol is different from variables in following aspects
• It is more like a string than variable
• In Ruby string is mutable but a Symbol is immutable
• Only one copy of the symbol requires to be created
• Symbols are often used as the corresponding to enums in Ruby
Explain what is Cross-Site Request Forgery (CSRF) and how Rails is protected against it?
CSRF is a form of attack where hacker submits a page request on your behalf to a different website, causing damage or revealing your sensitive data. To protect from CSRF attacks, you have to add “protect_from_forgery” to yourApplicationController. This will cause Rails to require a CSRF token to process the request. CSRF token is given as a hidden field in every form created using Rails form builders.
Mention what is the difference between the Observers and Callbacks in Ruby on Rails?
• Rails Observers: Observers is same as Callback, but it is used when method is not directly associated to object lifecycle. Also, the observer lives longer, and it can be detached or attached at any time. For example, displaying values from a model in the UI and updating model from user input.
• Rails Callback: Callbacks are methods, which can be called at certain moments of an object’s life cycle for example it can be called when an object is validated, created, updated, deleted, A call back is short lived. For example, running a thread and giving a call-back that is called when thread terminates.
Mention what is the difference between calling super() and super call?
• super(): A call to super() invokes the parent method without any arguments, as presumably expected. As always, being explicit in your code is a good thing.
• super call: A call to super invokes the parent method with the same arguments that were passed to the child method. An error will therefore occur if the arguments passed to the child method don’t match what the parent is expecting.
For more details on our products and services, please feel free to visit us at outsource ecommerce software, web developer freelancers, outsource psd to html, outsource web developer, outsource web developers
-- END ---
Share Facebook Twitter
Print Friendly and PDF DisclaimerReport Abuse
Contact Email [email protected]
Issued By outsource
Country United States
Categories Business
Last Updated August 1, 2019