You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would include columns for :documentable_id and :documentable_type.
It would include columns for :documentable and :type.
It would include a column for :polymorphic_type.
Q10. Are instance variables set within a controller method accessible within a view?
Yes, any instance variables that are set in an action method on a controller can be accessed and displayed in a view.
Yes, instance variables set within an action method are accessible within a view, but only when render is explicitly called inside the action method.
No, instance variables in a controller are private and are not accessible.
No, instance variables can never be set in a controller action method.
Q11. When a validation of a field in a Rails model fails, where are the messages for validation errors stored?
my_model.errors[:field]
my_model.get_errors_for(:field)
my_model.field.error
my_model.all_errors.select(:field)
Q12. If a database table of users contains the following rows, and id is the primary key, which statement would return only an object whose last_name is "Cordero"?
Q24. Given this controller code, which choice describes the expected behavior if parameters are submitted to the update action that includes values for the product's name, style, color, and price?
The product will not be updated and the edit template will be rendered.
The product will not be updated and the controller will raise an ActiveModel::ForbiddenAttributes exception.
The product will be updated with the values for name, style, and color, but the value for price will be ignored.
The product will be updated with the values for name, style, color, and price.
Q25. A Rails project has ActiveRecord classes defined for Classroom and Student. If instances of these classes are related so that students are assigned the ID of one particular classroom, which choice shows the correct associations to define?
Q48. Which part of the Rails framework is primarily responsible for making decisions about how to respond to a browser request?
view
controller
ActiveRecord
model
Q49. If User is an ActiveRecord class, which choice would be expected to return an array?
User.where(last_name: 'Smith')
User.find_or_create(last_name: 'Smith')
User.find_by_last_name('Smith')
User.find('Smith')
Q50. Which choice is not a valid Rails route?
route "products/index", to: "products/index", via: :get
match "products/index", to: "products#index", via: :get
root "products/index"
get "products/index"
Q51. 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?
Q52. Given this Category model with an attribute for "name", what code would fill in the blank so that it sets saved_name to a string that is the category name that existed before the name was changed?
classCategory < ActiveRecord::Base# has a database column for :nameendcategory=Category.firstcategory.name='News'saved_name=_____
category.name_was
category.saved(:name)
category.changes[:name]
category.name_changed?
Q53. Given two models, what is the issue with the query used to fetch them?