Ruby on Rails/Ruby on Rails Multiple choice Questions Set 1 Sample Test,Sample questions

Question:
.how do you start a loop that reads through the array object "@ads"?

1.a web page

2.ruby make

3.for ad in @ads

4.ActionPack


Question:
.if looping through “f” object, how do you make a text field “name”?

1.<%= yield %>

2.… have the same URL

3.<% form_for() %>

4. <%= f.text_field :name %>


Question:
.what are the three "magic columns"

1. id, created_at, updated_at

2.render :partial:id

3.integration test

4.rake db:migrate:id:delete


Question:
.what does "rake" mean?

1.#{1+1}

2.singular

3.ruby make

4.flight_id


Question:
.what's the difference between model names and controller names?

1.the method within the controller to call

2.the data being presented by the web page

3. model names are singular, controller (and table) names are plural d)

4.in the controller: respond_to do |format| ... end


Question:
.when data is retrieved from the database, what does Rails turn it into?

1.a responder object

2.validate

3.flight_id

4.an object


Question:
.why should partials generally use local variables?

1.because they make the partial less dependent on other code

2.the data being presented by the web page

3.their names begin with an underscore

4.the request parameters table


Question:
a RESTful application uses ... to define an interaction with the data.

1.a responder object

2.it is not associated with a model

3. HTTP methods (post, get, put, delete) d)

4.the request parameters table


Question:
converts database records to objects is called -------------.

1.for ad in @ads

2.integration test

3.Representational State Transfer

4. an object-relational mapping library


Question:
do models have singular or plural names?

1.controller

2.CamelCase

3.flight_id

4.singular


Question:
how do partials look compared to regular erb files?

1.underscores

2.it runs its validators

3.it is not associated with a model

4. their names begin with an underscore


Question:
how do you add an error (called "there was an error") in the validate method?

1.redirect_to " ... "

2. errors.add_to_base("there was an error")

3.the word "private"

4.their names begin with an underscore


Question:
how do you ask for all records of the Ads table?

1.singular

2.@ads = Ad.find(:all)

3.validate

4.rake db:migrate


Question:
how do you call a partial?

1.a web page

2.underscores

3.singular

4. render :partial


Question:
how do you create a migration that adds a "phone" field to the "tickets" table?

1.unit, functional, and integration tests

2.RAILS_ENV (RAILS_ENV=production)

3.integration test

4. rails generate migration AddPhoneToTickets phone:string


Question:
how do you express error messages in a form (do |f|)?

1.ruby make

2. f.error_messages

3.for ad in @ads

4.underscores


Question:
how do you generate regular model code (not scaffolding)?

1.just replace the word "scaffold" with the word "model"

2.it is not associated with a model

3.username == "admin" && password == "some_password"

4.do |f| (where "f" can be anything)


Question:
how do you run a migration?

1.CamelCase

2.ruby make

3.an object

4. rake db:migrate


Question:
how do you run the latest migrations?

1.ruby make

2.a web page

3. rake db:migrate

4.CamelCase


Question:
how do you specify a format like html or xml in routes.rb?

1.format (that period is a concatenation period)

2.HTTP methods (post, get, put, delete)

3.their names begin with an underscore

4.unit, functional, and integration tests


Question:
how do you update?

1.update_attributes (as in @ad.update_attributes(params[:ad]))

2.unit, functional, and integration tests

3.format (that period is a concatenation period)

4.it is not associated with a model


Question:
how does "rake" differ from "ruby"?

1.right after the line introducing the class in the controller

2.a script that alters the structure of the underlying database

3. it can do more complex things like modifying the database structure and running tests

4.expression is ruby code that prints out a value in html


Question:
how does Rails choose to correct format to generate?

1. in the controller: respond_to do |format| ... end

2.it is not associated with a model

3.redirect_to " ... "

4.the data being presented by the web page


Question:
how does rake tell which migrations have been run and which have not?

1.rails generate migration AddPhoneToTickets phone:string

2.rails records the latest timestamp of all the migrations it runs (and runs only the latest ones)

3.because they make the partial less dependent on other code

4.it can do more complex things like modifying the database structure and running tests


Question:
how should you order routes?

1.just replace the word "scaffold" with the word "model"

2. from general to specific ('/ads/' and then '/ads/:id')

3.rails generate migration AddPhoneToTickets phone:string

4.do |f| (where "f" can be anything)


Question:
how would you insert "1 + 1" into a string?

1.CamelCase

2.#{1+1}

3.singular

4.validate


Question:
if the table Seats is associated with the table Flights, how should you name the table column in Seats to indicate its flight?

1.an object

2.flight_id

3.ruby make

4.#{1+1}


Question:
Rails' application framework is called ----------?

1.ActionPack

2.ActiveRecord

3.a web page

4.an object


Question:
representation of a resource is called -------------.

1.CamelCase

2.ruby make

3. a web page

4.ActionPack


Question:
Ruby on Rails Multiple choice Questions

1.runs State test

2.the request State Transfer

3.Representational State Transfer

4.runs State Transfer


Question:
to add login security, which two pieces of code do you need?

1.1.all important data is a resource2. every resource has a proper name (URL)

2.:format (that period is a concatenation period)

3.the method within the controller to call

4. 1. login method (that checks a username and password) and 2. a filter (that calls the login method when needed)


Question:
to create scafolding for "thing" data, run...

1.because they make the partial less dependent on other code

2.expression is ruby code that prints out a value in html

3.just replace the word "scaffold" with the word "model"

4.rails generate scaffold thing <column name 1>:<column type1> <column name 2>:<column type2>


Question:
what checks if an input is numeric?

1.integration test

2.Fa responder object

3.validate

4.validates_numericality_of


Question:
what comes after <% form_for()... ?

1.redirect_to " ... "

2.the request parameters table

3.<%= f.text_field :name %>

4.do |f| (where "f" can be anything)


Question:
what comes after "def check_logged_in" line for site "ads"?

1.in the controller: respond_to do |format| ... end

2.errors.add_to_base("there was an error")

3.format (that period is a concatenation period)

4.authenticate_or_request_with_http_basic("Ads") do |username, password|


Question:
what does "show" refer to as the :action value?

1.the method within the controller to call

2.HTTP methods (post, get, put, delete)

3.the data being presented by the web page

4.their names begin with an underscore


Question:
what does a model object do before it saves or updates data?

1.underscores

2. it runs its validators

3.validate

4.rake db:migrate


Question:
what does Embedded Ruby (ERb) process as inputs?

1. data from model objects AND the page template

2.HTTP methods (post, get, put, delete)

3.it is not associated with a model

4.their names begin with an underscore


Question:
what does the "h" in <%=h ... %> mean?

1.:format (that period is a concatenation period)

2.h is a helper method that escapes special characters to sanitize malicious input

3.a script that alters the structure of the underlying database

4.the method within the controller to call


Question:
what environments does Rails have by default?

1.development, test, production

2.render :partial

3.RAILS_ENV (RAILS_ENV=production)

4.integration test


Question:
what expression do all layouts have?

1. <%= yield %>

2.<% form_for() %>

3.integration test

4.<%= f.text_field :name %>


Question:
what generates web pages from page templates?

1.underscores

2. Embedded Ruby (ERb)

3.a web page

4.render :partial


Question:
what is "format" in "repond_to do |format|"?

1.underscores

2.an object

3. a responder object

4.integration test


Question:
what is "migration"?

1.It is a format (that period is a concatenation period)

2.a script that alters the structure of the underlying database

3.their names begin with an underscore

4.the data being presented by the web page


Question:
What is bundler?

1.rails generate scaffold User name:string email:string

2.self-contained bundles of gems. Useful for versioning.

3. Edit Gemfile, then run 'bundle install' or just 'bundle'.

4.Ruby Version Manager. Install and manage multiple versions of Ruby.


Question:
What is gem?

1.rails generate scaffold User name:string email:string

2.self-contained packages of Ruby code

3.self-contained bundles of gems. Useful for versioning.

4.Ruby Version Manager. Install and manage multiple versions of Ruby.


Question:
What is gemset?

1.self-contained bundles of gems. Useful for versioning.

2.self-contained packages of Ruby code

3.Ruby Version Manager. Install and manage multiple versions of Ruby.

4.rails generate scaffold User name:string email:string


Question:
what is naming convention for classes?

1.ActionPack

2.CamelCase

3.ruby make

4.a web page


Question:
what is naming convention for file names ?

1.ActiveRecord

2.underscores

3.an object

4.validate


Question:
what is params[...]?

1.have the same URL of a table b)

2.the word "private"

3.a responder object

4. the request parameters table


Question:
what is Rails' object-relational mapping library?

1.CamelCase

2.ActiveRecord

3.an object

4.underscores


Question:
what is Rails' object-relational mapping library?

1.CamelCase

2.ActiveRecord

3.an object

4.underscores


Question:
What is rake?

1.self-contained bundles of gems. Useful for versioning.

2.bundle exec rake db:migrate. Using bundle exec ensures that the rake version in our Gemfile is used.

3.rails generate scaffold User name:string email:string

4.Ruby Version Manager. Install and manage multiple versions of Ruby.


Question:
What is rvm?

1.rails generate scaffold User name:string email:string

2. Ruby Version Manager. Install and manage multiple versions of Ruby.

3.self-contained bundles of gems. Useful for versioning.

4.self-contained packages of Ruby code


Question:
what is scaffold command?

1.rails generate scaffold User name:string email:string

2.Ruby Version Manager. Install and manage multiple versions of Ruby.

3.self-contained packages of Ruby code

4.self-contained bundles of gems. Useful for versioning.


Question:
what is scriptlet versus expression

1.it runs its validators

2.it is not associated with a model

3.Representational State Transfer

4. expression is ruby code that prints out a value in html


Question:
what is the filter code that calls on the "check_logged_in" method for only the "edit" and "update" methods?

1.the data being presented by the web page

2.HTTP methods (post, get, put, delete)

3.data from model objects AND the page template

4. before_filter :check_logged_in, :only => [:edit, :update]


Question:
what is the second uri indicate?

1.an object

2.ActionPack

3.CamelCase

4.controller


Question:
what kind of test do you create yourself?

1.an object

2.ActionPack

3.rake db:migrate

4. integration test


Question:
what kind of tests are there?

1.unit, functional, and integration tests

2.it is not associated with a model

3.id, created_at, updated_at

4.it runs its validators


Question:
what method name indicates to rails that it should validate before saving/updating?

1.validate

2.ActionPack

3.flight_id

4.ruby make


Question:
what parameters are in <% form_for() %>?

1.data from model objects AND the page template

2. form_for(@object, :url=>{:action=>'create'})

3.:format (that period is a concatenation period)

4.do |f| (where "f" can be anything)


Question:
what precedes the "check_logged_in" method in a class?

1.the request parameters table

2. the word "private"

3.<% form_for() %>

4.redirect_to " ... "


Question:
what scripts does the model-generator command create?

1.their names begin with an underscore

2. the model class (app/models/something.rb) and the data migration (db/migrate/..._create_something.rb)

3.model names are singular, controller (and table) names are plural

4.rails generate migration AddPhoneToTickets phone:string


Question:
what should you write in routes.rb to give meaning to http://mebay.com/ads/3?

1.from general to specific ('/ads/' and then '/ads/:id')

2.map.connect '/ads/:id', :controller=>'ads', :action=>'show'

3.include test.xml to root of "public" folder and ,render (:partial=>'map', :locals=>{:data=>'/test.xml'})

4.form_for(@object, :url=>{:action=>'create'})


Question:
what steps get you from fild.erb to file.html?

1.data from model objects AND the page template

2.erb -> Embedded Ruby -> ruby code (file.rb) -> fild.html

3.the method within the controller to call

4.the data being presented by the web page


Question:
what tag starts a form?

1.integration test

2.<%= f.text_field :name %>

3. <% form_for() %>

4.<%= yield %>


Question:
what variable changes the environment?

1.RAILS_ENV (RAILS_ENV=production)

2.development, test, production

3.render :partial d)

4.validates_numericality_of


Question:
what's special about a search form?

1.for ad in @ads

2. it is not associated with a model

3.Representational State Transfer

4.it runs its validators


Question:
when you put something into an array, does the array keep a separate copy?

1. no. arrays just keep references to objects stored in memory.

2.the data being presented by the web page

3.it is not associated with a model

4.the request parameters table


Question:
where do you add the filter code?

1.rails generate migration AddPhoneToTickets phone:string

2.the data being presented by the web page

3.data from model objects AND the page template

4. right after the line introducing the class in the controller


Question:
where do you edit routs?

1.controller

2.underscores

3.ActiveRecord

4.config/routes.rb


Question:
which two steps to include test.xml data to the partial "map" (via the variable "data")...?

1.from general to specific ('/ads/' and then '/ads/:id')

2.include test.xml to root of "public" folder and , render (:partial=>'map', :locals=>{:data=>'/test.xml'})

3.just replace the word "scaffold" with the word "model"

4.login method (that checks a username and password) and , a filter (that calls the login method when needed)


Question:
why do you only need to call "render" in the controller sometimes and not always?

1..:format (that period is a concatenation period)

2.redirect_to " ... "

3.errors.add_to_base("there was an error")

4. if you're happy with the default template, you can omit "render"


Question:
why is it good to redirect after inserting info into the database?

1.unit, functional, and integration tests

2.a script that alters the structure of the underlying database

3. so that users can't accidentally resubmit information by refreshing the page

4.the data being presented by the web page


More MCQS

  1. Ruby MCQ Questions
  2. Ruby on Rails Multiple choice Questions Set 1
  3. Ruby on Rails Multiple choice Questions Set 2
  4. Ruby on Rails Multiple choice Questions Set 3
  5. Ruby on Rails MCQ
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!