Spaces:
Sleeping
Sleeping
question,option1,option2,option3,option4,answer,difficulty | |
What does MVC stand for in Ruby on Rails?,Model View Controller,Model View Content,Master View Controller,Main Value Controller,Model View Controller,low | |
Which command creates a new Rails application?,rails new,rails generate,rails create,rails init,rails new,low | |
What is the default database used in a Rails application?,SQLite,PostgreSQL,MySQL,Oracle,SQLite,low | |
Which file defines the routes in a Rails application?,routes.rb,application.rb,config.rb,route.rb,routes.rb,low | |
Which method is used to define a route in Rails?,route(),resources(),map(),get(),resources(),low | |
What is ActiveRecord in Rails?,ORM framework,HTML rendering engine,API client,view helper,ORM framework,low | |
How do you create a new migration in Rails?,rails generate migration,rails generate model,rails create migration,rails make migration,rails generate migration,low | |
Which file contains the database configuration in Rails?,database.yml,db_config.rb,config.rb,db.yml,database.yml,low | |
Which command runs all the migrations in Rails?,rails db:migrate,rails db:setup,rails migrate,rails db:run,rails db:migrate,low | |
Which method is used to render a view in Rails?,render(),render_view(),show(),view(),render(),low | |
How do you define a model in Rails?,class Model < ActiveRecord::Base,model Model < ApplicationRecord,class Model < ApplicationRecord,model class Model,class Model < ActiveModel::Base,class Model < ActiveRecord::Base,low | |
What is the primary purpose of the `rails console`?,To test Rails commands,To interact with the Rails application in the terminal,To view Rails logs,To run Rails migrations,To interact with the Rails application in the terminal,low | |
Which of the following is used to define a route for a RESTful resource?,resources :model,resource :model,route :model,get :model,resources :model,low | |
What does `rails server` start?,A test environment,A development server,The production server,The database,A development server,low | |
What is the purpose of `rails db:seed`?,To generate the schema,To load seed data into the database,To run all migrations,To initialize the application,To load seed data into the database,low | |
What is the default view engine used in Rails?,ERB,HAML,SLIM,HTML,ERB,low | |
Which of the following is not a Rails helper?,link_to,render,form_for,find,find,low | |
What is the purpose of the `before_action` callback?,To execute code before a controller action,To execute code after a controller action,To define a default value,To fetch data before rendering a view,To execute code before a controller action,low | |
How do you create a new controller in Rails?,rails generate controller,rails generate model,rails create controller,rails create controller,rails generate controller,low | |
Which method is used to generate a new resource in Rails?,rails generate scaffold,rails generate resource,rails create resource,rails generate model,rails generate scaffold,low | |
What is the purpose of the `belongs_to` association in Rails?,To set up a one-to-one relationship,To set up a one-to-many relationship,To set up a many-to-many relationship,To create a nested resource,To set up a one-to-one relationship,low | |
How do you add a new column to an existing table in Rails?,rails generate migration,rails db:migrate,rails db:add_column,rails generate model,rails generate migration,medium | |
Which of the following is the correct way to render a partial in Rails?,render 'partial',render partial(),render 'partial.html.erb',render 'shared/partial',render 'partial',medium | |
How do you store session data in Rails?,In a database,in cookies,in a file,in memory,in a database,medium | |
What is the purpose of the `has_many` association in Rails?,To set up a one-to-one relationship,To set up a one-to-many relationship,To set up a many-to-many relationship,To create a nested resource,To set up a one-to-many relationship,medium | |
Which of the following is used to test models in Rails?,RSpec,FactoryBot,Cucumber,Test::Unit,RSpec,medium | |
What does the `strong_parameters` feature do in Rails?,Prevents mass assignment vulnerabilities,Encrypts parameters,Validates input parameters,Filters session data,Prevents mass assignment vulnerabilities,medium | |
How do you validate the presence of a field in Rails?,validates :field,validates_presence_of :field,validates_field :field,validates_presence :field,validates_presence_of :field,medium | |
Which file stores the database schema in Rails?,schema.rb,config.rb,migration.rb,db_config.rb,schema.rb,medium | |
What method is used to delete a record from the database in Rails?,destroy(),delete(),remove(),destroy_all(),destroy(),medium | |
What is the purpose of `flash` in Rails?,To store temporary messages,To store session data,To handle errors,To render partials,To store temporary messages,medium | |
What is the correct way to create a new migration for adding a column to a table?,rails generate migration AddColumnToTable,column:type,rails generate migration AddColumnToTable,column:type,rails create migration AddColumnToTable,column:type,rails create migration AddColumn,column:type,rails generate migration AddColumnToTable,column:type,medium | |
Which of the following is used to render an HTML form in Rails?,form_for,form_tag,render_form,form,form_for,medium | |
What is the use of `active_record` in Rails?,It connects models to the database,It handles routing,It handles the session data,It renders views,It connects models to the database,medium | |
How do you include JavaScript and CSS files in Rails?,Using the asset pipeline,Using a CDN,Including in the layout file,Using JavaScript include tags,Using the asset pipeline,medium | |
How do you define a scope in a Rails model?,scope :name,scope :name => ,scope :name do ,scope do,scope :name,medium | |
What is the main benefit of using Rails' built-in authentication?,Ease of use,Security,Flexibility,Customization,Security,medium | |
Which of these is used to send email in Rails?,ActionMailer,Mailer,Emailer,ActionView,ActionMailer,medium | |
What is the purpose of `rails db:reset`?,To reset the database schema,To run migrations,To drop and recreate the database,To seed the database,To drop and recreate the database,medium | |
How do you create a polymorphic association in Rails?,use `polymorphic: true` in the model,create a join table,add a foreign key,create a has_many relationship,use `polymorphic: true` in the model,high | |
What is the purpose of the `rails test` command?,Run all tests,Run unit tests,Run only model tests,Run functional tests,Run all tests,high | |
How do you create a database index in Rails?,add_index,create_index,create_index_in,migration_index,add_index,high | |
What is the correct way to create a database constraint in Rails?,use `add_foreign_key`,use `add_constraint`,use `validates_uniqueness_of`,use `add_check_constraint`,use `add_foreign_key`,high | |
How do you implement background jobs in Rails?,Sidekiq,ActiveJob,Resque,DelayedJob,ActiveJob,high | |
What is the purpose of `rails assets:precompile`?,Prepares assets for production,Deletes unused assets,Generates a sitemap,Prepares assets for development,Prepares assets for production,high | |
How do you add a unique constraint to a column in Rails?,validates_uniqueness_of,add_index with unique:true,add_constraint,validates_uniqueness,add_index with unique:true,high | |
Which Rails feature allows easy database querying?,ActiveRecord,ActiveJob,ActionCable,ActionMailer,ActiveRecord,high | |
What is the default Rails logger?,Logger,ActiveLogger,Log4r,ConsoleLogger,Logger,high | |
How do you configure Rails to use a different database in production?,Change the `database.yml` file,Change `config/database.rb`,Set an environment variable,Use a configuration initializer,Change the `database.yml` file,high | |
What is the purpose of `rails generate scaffold`?,Generates full resource code,Generates only a model,Generates only a controller,Generates only a migration,Generates full resource code,high | |
What is the main advantage of using `ActiveStorage` in Rails?,Uploading files easily,Sending email,Handling session data,Managing forms,Uploading files easily,high | |
How do you define a nested resource in Rails?,resources :parent do resources :child,end,resources :parent/child,resource :child,resources :parent/child,end,resources :parent do resources :child,end,high | |
How do you define a default value for a model attribute in Rails?,Use `default` in the database migration,Use `default` in the model,Use `default_value` method,Use `default_value` in the migration,Use `default` in the database migration,high | |
How do you handle file uploads in Rails?,ActiveStorage,FileUpload,CarrierWave,ActionMail,ActiveStorage,high | |
What does the `has_secure_password` method do in Rails?,Encrypts and authenticates passwords,Encrypts passwords only,Authenticates users,Generates a password hash,Encrypts and authenticates passwords,high | |
How do you configure Rails to use a different caching system?,Edit `config/environments/production.rb`,Edit `config/database.yml`,Edit `config/caching.rb`,Edit `config/initializers/cache.rb`,Edit `config/environments/production.rb`,high | |