UsersController class following the convention over configuration principle?Rails expects controller files to be named in snake_case matching the controller class name. For UsersController, the file should be users_controller.rb. This is a key example of convention over configuration.
ProductCategory, what is the default database table name Rails will use without any configuration?Rails automatically converts model class names from CamelCase to snake_case and pluralizes them to get the table name. So ProductCategory becomes product_categories.
resources :orders, which helper method will generate the path to the new order form following Rails conventions?Rails generates route helper methods based on resource names. For the new form of orders, the helper is new_order_path.
ArticlesController. You created a view template named show.html.erb inside the folder app/views/article. Why does Rails not render this template by default?Rails expects the view folder to be the pluralized form of the controller name. Since the controller is ArticlesController, the folder must be articles, not article.
class User < ApplicationRecord
has_many :posts
endclass Post < ApplicationRecord
belongs_to :author, class_name: 'User'
endWhat will happen if you try to access
post.author without specifying the foreign key in the Post model, assuming the posts table has a user_id column?When you use belongs_to :author, class_name: 'User', Rails expects a foreign key named author_id by default. Since the table has user_id instead, Rails cannot find the association without specifying foreign_key: 'user_id'.