Ruby on Rails MCQ Quiz Hub

Ruby on Rails Multiple choice Questions Set 3

Choose a topic to test your knowledge and improve your Ruby on Rails skills

1. What command do you run to undo the last 5 migrations




2. A global variable has a name beginning with:




3. What gets returned by: [1, [2, 3,[4, 5]]].flatten




4. How can you create a new Rails project?




5. Which of the following will delete the key-value 1 from array: "big_data"




6. What is the use of $ in Ruby?




7. Which code sample will skip running the login_required "before" filter on the get_posts controller action?




8. Which is NOT a default Rails environment?




9. What is a Gem?




10. Which extension is default for views html templates?




11. In the MVC pattern:




12. What is the command to install Rails?




13. What command do you run to create your database?




14. What command do you run to drop your database?




15. How would you declare an Instance Variable?




16. Ruby uses:




17. What command do you run to update your database?




18. Migrations...




19. What is the preferred method of validating that the name has been set?




20. Which of the following will interpolate within a string with the variable named 'monster'?




21. What is the output of the following ? s="foo" * 2 puts s




22. What ORM does Ruby on Rails use by default?




23. What is a typical file extension found in the app/controllers directory




24. Which of these is not a standard directory in a Rails application?




25. The recommended directory in which to place your app's javascript files is:




26. Which files is used to specify any default data that should be loaded into the application's database, when it is first setup?




27. What is the default value for a global variable (before initialization)?




28. Which of the following prints the "Hello WORLD!" output with a new line?




29. How do you create a new user object with the name david and save it to the database?




30. Which of these does NOT correctly return the version of Ruby?




31. If you want the /person url to map to your dog controller and show method, what do you add to your routes?




32. What is the use of the 'defined?' method?




33. Which of these javascript frameworks became the default with the release of Rails 3.1?




34. When Ruby methods add an exclamation point at the end of their name (such as sort!), what does it typically indicate?




35. Which Rails helper would you use in the application view to protect against CSRF (Cross-Site Request Forgery) attacks?




36. In a Rails controller, what does the code params.permit(:name, :sku) do?




37. Review the code below. Which Ruby operator should be used to fill in the blank so that the sort method executes properly? [5,8,2,6,1,3].sort {|v1,v2| v1 ___ v2}




38. Which statement about ActiveRecord models is true?




39. Which choice best describes the expected value of @result? @result = Article.first.tags.build(name: 'Urgent')




40. Which part of the Rails framework is primarily responsible for making decisions about how to respond to a browser request?




41. If User is an ActiveRecord class, which choice would be expected to return an array?




42. Which choice is not a valid Rails route?




43. Given a table of blog_posts and a related table of comments (comments made on each blog post), which ActiveRecord query will retrieve all blog posts with comments created during @range?




44. Which choice is an incorrect way to render a partial?