<%= collection_select(:product, :product_id, Product.all, :id, :name) %>
Answer
Correct Answer:
<%= collection_select(:product, :product_id, Product.all, :id, :name) %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
29. 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)
Answer
Correct Answer:
My_model.errors[:field]
Note: This Question is unanswered, help us to find answer for this one
Check Answer
30. 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.
Answer
Correct Answer:
Yes, any instance variables that are set in an action method on a controller can be accessed and displayed in a view.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
31. Which ActiveRecord query prevents SQL injection?
Product.where(
Product.where(
Product.where(
Product.where(
Answer
Correct Answer:
Product.where(
Note: This Question is unanswered, help us to find answer for this one
Check Answer
32. Which choice includes standard REST HTTP verbs?
GET, POST, PATCH, DELETE
REDIRECT, RENDER, SESSION, COOKIE
INDEX, SHOW, NEW, CREATE, EDIT, UPDATE, DESTROY
CREATE, READ, UPDATE, DELETE
Answer
Correct Answer:
GET, POST, PATCH, DELETE
Note: This Question is unanswered, help us to find answer for this one
Check Answer
33. In Rails, which code would you use to define a route that handles both the PUT and PATCH REST HTTP verbs?
Put :items, include: patch
Put 'items', to: 'items#update'
Match 'items', to 'items#update', via: [:put, :patch]
Match :items, using: put && patch
Answer
Correct Answer:
Match 'items', to 'items#update', via: [:put, :patch]
Note: This Question is unanswered, help us to find answer for this one
Check Answer
34. Which module can you use to encapsulate a cohesive chunk of functionality into a mixin?
ActiveSupport::Concern
RailsHelper.CommonClass
ActiveJob::Mixin
ActiveSupport::Module
Answer
Correct Answer:
ActiveSupport::Concern
Note: This Question is unanswered, help us to find answer for this one
Check Answer
35. What is before_action (formerly known as before_filter)?
A trigger that is executed before an alteration of an object's state
A method that is executed before an ActiveRecord model is saved
A callback that fires before an event is handled
A method in a controller that is executed before the controller action method
Answer
Correct Answer:
A method in a controller that is executed before the controller action method
Note: This Question is unanswered, help us to find answer for this one
Check Answer
36. Which statement correctly describes a difference between the form helper methods form_tag and form_for?
The form_tag method is for basic forms, while the form_for method is for multipart forms that include file uploads.
The form_tag method is for HTTP requests, while the form_for method is for AJAX requests.
The form_tag method typically expects a URL as its first argument, while the form_for method typically expects a model object.
The form_tag method is evaluated at runtime, while the form_for method is precompiled and cached.
Answer
Correct Answer:
The form_tag method typically expects a URL as its first argument, while the form_for method typically expects a model object.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
37. Within a Rails controller, which code will prevent the parent controller's before_action :get_feature from running?
Skip_before_action :get_feature
Skip :get_feature, except: []
Prevent_action :get_feature
:redis_cache_store
Answer
Correct Answer:
Skip_before_action :get_feature
Note: This Question is unanswered, help us to find answer for this one
Check Answer
38. When rendering a partial in a view, how would you pass local variables for rendering?
<%= render partial:
<%= render partial:
<%= render partial:
Answer
Correct Answer:
<%= render partial:
Note: This Question is unanswered, help us to find answer for this one
Check Answer
39. What does the expression x ||= y mean?
x = y when x == false, otherwise x remains unchanged
x = y when x == true, otherwise x remains unchanged
x = y when x == true, otherwise x remains unchanged
x = y when y == true, otherwise x remains unchanged
Answer
Correct Answer:
x = y when x == false, otherwise x remains unchanged
Note: This Question is unanswered, help us to find answer for this one
Check Answer
40. Which of the following gems is used for authentication in Ruby on Rails? (check any that apply)
Devise
OmniAuth
Authlogic
None of these
Answer
Correct Answer:
Devise OmniAuth Authlogic
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
41.
What is the CGI Library? (check any that apply)
CGI data processing routines
Parses incoming form data
Part of the Ruby standard library
None of the above
Answer
Correct Answer:
CGI data processing routines Part of the Ruby standard library
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
42.
The send_data method has the following options? send_data(data, options = {})
:filename Suggests a filename for the browser to use
:type Specifies an HTTP content type. Defaults to ‘application/octet-stream’
:disposition Specifies whether the file will be shown inline or downloaded. Valid values are inline and attachment (default)
:status Specifies the status code to send with the response. Defaults to ‘200 OK’
All of the above
Answer
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Check Answer
43.
Which of these codes will print correct date?
format('Birthday: #{month}/#{day}/#{year}', day: 14, month: 11, year: 1994) format('Birthday: %d/%d/%d', 11, 14, 1994)
format('Birthday: %{month}/%{day}/%{year}', day: 14, month: 11, year: 1994) format('Birthday: %{month}/%{day}/%{year}', 11, 14, 1994)
1st
2nd
3rd
4th
All of these
None of these
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
44.
Which of these files are located by default in "config” directory? (check any that apply)
application.rb
config.ru
environment.rb
assets.rb
Answer
Correct Answer:
application.rb environment.rb
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
45.
Which of these filters do no exist in Rails controller? (check any that apply)
before_action
after_action
skip_action_callback
skip_before_callback
skip_after_callback
Answer
Correct Answer:
skip_action_callback skip_before_callback skip_after_callback
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
46.
Which of these folders do not exist in folder “app” in Rails 5? (check any that apply)
assets
vendor
jobs
channels
services
Answer
Correct Answer:
vendor services
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
47.
Which of these URL's will not be created by method resources :posts in routes.rb?
GET /posts
POST /posts/create
DELETE /posts/:id/delete
PATCH /posts/:id
Answer
Correct Answer:
POST /posts/create DELETE /posts/:id/delete
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
48.
Which of these statements about Ruby on Rails 5 are false?
Added ActionCable
Rails API gem merged in core of Rails
Added ApplicationRecord top-level model
Relation "has_one" is required by default
Terminal command "rails" replaced by "rake"
Answer
Correct Answer:
Relation "has_one" is required by default Terminal command "rails" replaced by "rake"
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
49.
Why would let() be used in rspec?
let() is being used as a kind of setup() and it relies on the relationships
Use it once and the result is persisted across the rspec tests.
let() is very slow and therefore is not generally used
let() always invoked before initialization
Answer
Correct Answer:
let() always invoked before initialization
Note: This Question is unanswered, help us to find answer for this one
Check Answer
50.
What is the SQL equivalent of following code? user=User.take(3)
SELECT *from users limit 1
SELECT *from users where users.id=3
SELECT *from users limit 3
SELECT *from users limit 2
Answer
Correct Answer:
SELECT *from users limit 3
Note: This Question is unanswered, help us to find answer for this one
Check Answer
51.
Which of the following code snippet can be used to include all javascript files?
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
<%= link_to ... %>
Answer
Correct Answer:
<%= javascript_include_tag :defaults %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
52. Which of the following code snippet can be used to include all javascript files?
http_basic_auth
http_basic_authenticate
http_basic_auth_with
http_basic_authenticate_with
Answer
Correct Answer:
http_basic_authenticate_with
Note: This Question is unanswered, help us to find answer for this one
Check Answer
53.
Which following command will you use in Updates Ruby in the latest version?
gem update
gem update –system
gem update –system
All of the above
Answer
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Check Answer
54.
While installing Ruby, why do you sometimes get a missing "psych” error?
It seems your Ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your Ruby.
Ruby is not able to find yaml while installing.
All of the above
None of the above
Answer
Correct Answer:
It seems your Ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your Ruby.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
55.
Which of the following code is correct about Creating links
%= link_to “Button”, {:action => “action_name”,:id => product} :confirm => “some text here” %>
<%= link_to “Button”, {:action => “action_name”, :id => product}, :confirm => “some text here” %>
<%= link_to “Button”, {:action => “action_name”,id => product},confirm => “some text here” %>
<%= link_to “Button”, {:action = “action_name”,:id = product},:confirm = “some text here” %>
Answer
Correct Answer:
<%= link_to “Button”, {:action => “action_name”, :id => product}, :confirm => “some text here” %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
56.
What is the top-level model class added in Ruby on Rails 5?
ApplicationModel
ActiveModel
ApplicationRecord
BaseRecord
Answer
Correct Answer:
ApplicationRecord
Note: This Question is unanswered, help us to find answer for this one
Check Answer
57.
Which type of field is recommended for storing “enum" in Rails?
string
text
integer
decimal
Note: This Question is unanswered, help us to find answer for this one
Check Answer
58.
Which of these servers is the default development server for Ruby on Rails 5?
Thin
Puma
WEBrick
Phusion Passenger
Note: This Question is unanswered, help us to find answer for this one
Check Answer
59.
Which of these model methods will be generated by this code? enum state: { blocked: 0, active: 1 }
Model.states
blocked?
active!
All of these
None of these
Answer
Correct Answer:
Model.states
Note: This Question is unanswered, help us to find answer for this one
Check Answer
60.
Which of these methods catch Exception in Rails controllers?
raise_from
rescue_from
catch_raise
catch_rescue
Answer
Correct Answer:
rescue_from
Note: This Question is unanswered, help us to find answer for this one
Check Answer
61.
Which of these routes is not generated by “resource :user”?
GET /user
GET /user/1
GET /user/new
PATCH /user
Answer
Correct Answer:
GET /user/new
Note: This Question is unanswered, help us to find answer for this one
Check Answer
62.
Which of the following open directly is correct about Open URI?
open('http://www.example.com') { data results => data.read }
open('http://www.example.com') { | data | results = data.read }
open('http://www.example.com') { data | results = data.open }
open(http://www.example.com) { data => results = data.read }
Answer
Correct Answer:
open('http://www.example.com') { | data | results = data.read }
Note: This Question is unanswered, help us to find answer for this one
Check Answer
63.
Which of these codes will raise an exception? class Person def name 'Andrew' end end # 1. person = Person.new person .name # 2. person = Person.new person. name # 3. Person .new .name # 4. Person .name
1st
2nd
3rd
4th
None of these
Answer
Correct Answer:
None of these
Note: This Question is unanswered, help us to find answer for this one
Check Answer
64.
Which of the following is the correct way to add a field in a signup that is not present in the User Model?
Use a nested attribute with the Devise Model.
Create a Controller.
It will throw Activerecord::UnknownAttributeError if try to add the other field.
It will throw Activerecord::UnknownModelField if try to add the other field.
Answer
Correct Answer:
Use a nested attribute with the Devise Model.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
65.
Which of these expressions is equivalent to this code? a ||= "string"
a || a = "string"
a = "string" if a.blank?
a = "string" if !defined?(a) || !a
a = "string" if !defined?(a) || a.blank?
Answer
Correct Answer:
a || a = "string"
Note: This Question is unanswered, help us to find answer for this one
Check Answer
66.
Which of the following represents the inverse of a has_one association?
belong_to
has_none
belongs_to
None of the above
Answer
Correct Answer:
belongs_to
Note: This Question is unanswered, help us to find answer for this one
Check Answer
67.
In order to use optimistic locking, the table needs to have a column called ___________ of type integer.
lock_version
optimistic_version
lock_versions
lock
Answer
Correct Answer:
lock_version
Note: This Question is unanswered, help us to find answer for this one
Check Answer
68.
Which character is used to declare a global variable?
@@
$
@
_
Note: This Question is unanswered, help us to find answer for this one
Check Answer
69.
Which notation is used to create class variables?
@
@@
$
__
Note: This Question is unanswered, help us to find answer for this one
Check Answer
70.
render method does not accept ________________
content_type
layout
location
formats
language
Note: This Question is unanswered, help us to find answer for this one
Check Answer
71.
Which method is used to render partial templates as part of a view?
view
show
render
partial
Note: This Question is unanswered, help us to find answer for this one
Check Answer
72.
Which of the following types of association is not supported by ActiveRecord?
one-to-one
one-to-many
many-to-one
many-to-many
Answer
Correct Answer:
many-to-one
Note: This Question is unanswered, help us to find answer for this one
Check Answer
73.
Which helper should be used when your model has association with other models and they also need to be validated?
validates_associated
confirmation
acceptance
associate_validated
Answer
Correct Answer:
validates_associated
Note: This Question is unanswered, help us to find answer for this one
Check Answer
74.
State whether True or False The find method will raise an ActiveRecord::RecordNotFound exception unless a matching record is found for all the supplied primary keys.
True
False
Note: This Question is unanswered, help us to find answer for this one
Check Answer
75.
What is the difference between find() and find_by_id() method?
find_by_id() will raise an error in case record does not exist for a given primary key whereas find() will not raise an error and will return nil
find() will raise an error in case record does not exist for a given primary key whereas find_by_id() will not raise an error and will return nil
Both are same
None of the above
Answer
Correct Answer:
find() will raise an error in case record does not exist for a given primary key whereas find_by_id() will not raise an error and will return nil
Note: This Question is unanswered, help us to find answer for this one
Check Answer
76.
How to disable protection of CSRF attacks for API requests?
protect_from_forgery with: :exception
protect_from_forgery with: :api_ingore
protect_from_forgery with: :null_session
protect_from_forgery with: :ignore
Answer
Correct Answer:
protect_from_forgery with: :null_session
Note: This Question is unanswered, help us to find answer for this one
Check Answer
77.
Which method is used in views to prevent CSRF attack?
csrf_prevent_meta_tag
csrf_protect_meta_tag
csrf_meta_tag
csrf_tag
Answer
Correct Answer:
csrf_meta_tag
Note: This Question is unanswered, help us to find answer for this one
Check Answer
78.
Which of the following methods can be used inside a controller to prevent CSRF attack?
protect_from_forgery
protect_from_csrf
prevent_from_forgery
prevent_from_csrf
Answer
Correct Answer:
protect_from_forgery
Note: This Question is unanswered, help us to find answer for this one
Check Answer
79.
What is the difference between Lambdas and procs?
Procs check the number of arguments passed and will return an error if you try to pass the wrong number while Lambdas set extra variables to nil
Lambdas check the number of arguments passed and will return an error if you try to pass the wrong number while Procs set extra variables to nil
Procs can handle a return function whereas Lambdas will return error
There is no difference as both are same
Answer
Correct Answer:
Lambdas check the number of arguments passed and will return an error if you try to pass the wrong number while Procs set extra variables to nil
Note: This Question is unanswered, help us to find answer for this one
Check Answer
80.
Which file contains the database credentials of an RoR application?
config.yml
database.xml
database.yml
config.xml
Answer
Correct Answer:
database.yml
Note: This Question is unanswered, help us to find answer for this one
Check Answer
81. Which of the following rake commands can be used to load a schema.rb file into the database?
rake db:schema:dump
rake:db:schema:load
rake:db:migrate
rake:db:schema:clone
Answer
Correct Answer:
rake:db:schema:load
Note: This Question is unanswered, help us to find answer for this one
Check Answer
82.
Which file contains the Gem requirements of an RoR App?
Gemfile
Rakefile
config
bundle
Note: This Question is unanswered, help us to find answer for this one
Check Answer
83.
Which of the following command is used to list all the routes of an RoR application?
rake routes
rake route
bundle routes
routes
Answer
Correct Answer:
rake routes
Note: This Question is unanswered, help us to find answer for this one
Check Answer
84.
Which of the following is used to achieve multiple inheritance in Ruby?
plugin
module
mixin
class
Note: This Question is unanswered, help us to find answer for this one
Check Answer
85.
Which declaration can be used to override the default layout conventions in your controllers?
views
template
layout
partial
Note: This Question is unanswered, help us to find answer for this one
Check Answer
86.
Which of the following loops is not supported by Ruby?
While
For
Unless
Untill
Note: This Question is unanswered, help us to find answer for this one
Check Answer
87.
The belongs_to association supports following options?
A) :autosavename, :class_id
B) :primary_key, :validate, :optional
C) :conuter_cache, :inverse_of, :foreign_key
D) :dependent, :polymorphic, :touch
A
B
C
D
B, C & D
Note: This Question is unanswered, help us to find answer for this one
Check Answer
88.
The has_one association supports following options?
A):autoload, :validated
B):class_id, : foreign_name
C):dependent, :primary_key, :source_type
D):foreign_key, :inverse_of, :source
E)C,D
Note: This Question is unanswered, help us to find answer for this one
Check Answer
89.
Which of these options for “dependent” do not exist in Rails?
:destroy
:nullify
:restrict_with_exception
:restrict_with_error
All of these options exist
Answer
Correct Answer:
All of these options exist
Note: This Question is unanswered, help us to find answer for this one
Check Answer
90.
How is it possible to create combined unique index for two fields?
add_index :project_users, :user_id, combine_with: :project_id, unique: true
add_index :project_users, [:user_id, :project_id], unique: true
add_index :project_users, :user_id, unique: true add_index :project_users, :project_id, unique: true
add_index :project_users, :user_id, unique: true do add_index :project_users, :project_id, unique: true end
Answer
Correct Answer:
add_index :project_users, [:user_id, :project_id], unique: true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
91.
How do you permit nester attributes in Rails controllers for such model? class User has_one :profile accepts_nested_attributes_for :profile end
params.require(:user).permit(:email, profile: [:id, :_destroy])
params.require(:user).permit(:email, profile: {:id, :_destroy})
params.require(:user).permit(:email, profile_attributes: [:id, :_destroy])
params.require(:user).permit(:email, profile_attributes: {:id, :_destroy})
Answer
Correct Answer:
params.require(:user).permit(:email, profile_attributes: [:id, :_destroy])
Note: This Question is unanswered, help us to find answer for this one
Check Answer
92. Which of the following statements are correct about Types of Templates? (choose all that apply)
rxml,Files with Ruby code using the Builder library to generate XML
rhtml,They are HTML files with embedded Rails and they use the ERb library
rjs,Ruby code with Rails specific API that generate JavaScript.Used for Ajax functionality
All of the above
Answer
Correct Answer:
rxml,Files with Ruby code using the Builder library to generate XML
Note: This Question is unanswered, help us to find answer for this one
Check Answer
93.
The following methods skip validations, and will save the object to the database regardless of its validity?
A)update_all, update_attribute,update_column
B)decrement_counter, decrement!
C)increment!, update_counters
D)increment_count, update_tables
E)A,B,C
Note: This Question is unanswered, help us to find answer for this one
Check Answer
94.
What is the difference between "has_many :through" and "has_and_belongs_to_many"?
"has_many :through" requires an additional table in the database, whereas "has_and_belongs_to_many" does not
"has_many :through" requires an additional data model, whereas "has_and_belongs_to_many" does not
You should use "has_and_belongs_to_many" if you need validations, callbacks or extra attributes on the join model
No differences between these relations
Answer
Correct Answer:
You should use "has_and_belongs_to_many" if you need validations, callbacks or extra attributes on the join model
Note: This Question is unanswered, help us to find answer for this one
Check Answer
95. What is the purpose of using below code in filter_parameter_logging.rb? Rails.application.config.filter_parameters += [:password]
Remove “password” from input parameters
Disallow to send “password” via GET request
Hide "password" parameter in applications logs
Automatically trim whitespaces of “password” parameter
Answer
Correct Answer:
Hide "password" parameter in applications logs
Note: This Question is unanswered, help us to find answer for this one
Check Answer
96.
A controller is a server-side _____ of Rails that responds to external requests from the web server to the application?
Script
Component
Data
View
Answer
Correct Answer:
Component
Note: This Question is unanswered, help us to find answer for this one
Check Answer
97.
In Ruby on Rails, an action is typically a basic ____ that describes how to respond to a specific external web-browser request?
Unit
Render
Helper
Controller
Note: This Question is unanswered, help us to find answer for this one
Check Answer
98.
Which of the following instances are variables in your functional tests? (check any that apply)
@controller - The controller processing the request
@request - The request object
@response - The response object
@posts – The post object
Answer
Correct Answer:
@controller - The controller processing the request @request - The request object @response - The response object
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
99.
What are the Available callbacks? (check any that apply)
around_enqueue
after_enqueue
before_perform
around_perform
None of the above
Answer
Correct Answer:
around_enqueue after_enqueue before_perform around_perform
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
100.
Which of these is not a valid Bundler command?
bundle exec
bundle console
bundle config
bundle deps
Answer
Correct Answer:
bundle deps
Note: This Question is unanswered, help us to find answer for this one
Check Answer
101.
What are the asset tag helpers available in Rails? (check any that apply)
auto_discovery_link_tag
javascript_link_tag
stylesheet_link_tag
image_tag
All of the above
Answer
Correct Answer:
auto_discovery_link_tag stylesheet_link_tag image_tag
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
102.
The following methods trigger validations, and will save the object to the database only if the object is valid? (check any that apply)
create
create!
update
update!
None of the above
Answer
Correct Answer:
create create! update
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
103.
Calls to the render method generally accept using the following options?
A):content_id
B):layout_type
C):location
D):status and :formats
E)C,D
Note: This Question is unanswered, help us to find answer for this one
Check Answer
104.
What is the lowest version of Ruby supported by Ruby on Rails 5?
Ruby 2.0.0
Ruby 2.1.9
Ruby 2.2.2
Ruby 2.3.0
Answer
Correct Answer:
Ruby 2.2.2
Note: This Question is unanswered, help us to find answer for this one
Check Answer
105.
Which of the following statements is correct?
:rel specifies the rel value in the link. The default value is "alternate"
:type specifies an explicit MIME type. Rails will generate an appropriate MIME type automatically
:title specifies the title of the link. The default value is the uppercase:type value, for example, "ATOM" or "RSS"
All of the above
Answer
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Check Answer
106.
Please select the True statements from the following:
ActiveRecord - Talks to the database system and creates Ruby objects modeled on the database tables
ActionController - Manipulates ActiveRecord objects, loads data into variables for use in ActionView templates and uses CGI library to process form data held in CGI variables
ActionView - Fills ERB templates with data processed by ActionController, then hands the resulting HTML to the Web server
Support libraries, ActiveRecord ActionWebServices ActionMail
All of the above
Answer
Correct Answer:
ActiveRecord - Talks to the database system and creates Ruby objects modeled on the database tables ActionController - Manipulates ActiveRecord objects, loads data into variables for use in ActionView templates and uses CGI library to process form data held in CGI variables ActionView - Fills ERB templates with data processed by ActionController, then hands the resulting HTML to the Web server
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
107.
Which of the following types of callbacks are available in ROR?
A) (1) before_validated (2) after_validated
B) (3) before_save (4) before_create
C) (5) after_create (6) after_save (7) after_commit
D) B & C
Note: This Question is unanswered, help us to find answer for this one
Check Answer
108.
What is the difference between jruby and ruby?
Ruby is a programming language. JRuby is an implementation of the Ruby programming language.
JRuby is the ruby implementation that runs on a JVM whereas Matz's ruby is a C implementation.
All of the above.
None of the above.
Answer
Correct Answer:
All of the above.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
109.
Which of these options is right to create default scope of model in Rails?
scope, -> { order(:position) }
scope :default, -> { order(:position) }
default_scope -> { order(:position) }
default_scope, -> { order(:position) }
Answer
Correct Answer:
default_scope -> { order(:position) }
Note: This Question is unanswered, help us to find answer for this one
Check Answer
110.
Which of these files determine Ruby version and gemset for RVM library?
.rb-version, .rb-gemset
.ruby-version, .ruby-gemset
.version, .gemset
.rvm-version, .rvm-gemset
Answer
Correct Answer:
.ruby-version, .ruby-gemset
Note: This Question is unanswered, help us to find answer for this one
Check Answer
111.
Which of the following statements is true regarding the find_or_create method in Ruby on Rails?
It can find multiple arguments by using Model.find_or_create_by_name('name here'). It will first find the record and if it doesn't exist it will create it.
It cannot be used in Ruby on Rails.
It is similar to the find query.
It is similar to the create query.
Answer
Correct Answer:
It can find multiple arguments by using Model.find_or_create_by_name('name here'). It will first find the record and if it doesn't exist it will create it.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
112.
Which of the following protects "NOT NULL" fields against missing a user input?
validates_acceptance_of
validates_presence_of
validates_numericality_of
validates_confirmation_of
Answer
Correct Answer:
validates_presence_of
Note: This Question is unanswered, help us to find answer for this one
Check Answer
113.
Which of the following is not an advantage of using an integrated development environment (IDE) for Rails ,compared with using a simple text editor?
automated code analysis
assisted refactoring
smaller memory footprint
integrated version control
Answer
Correct Answer:
smaller memory footprint
Note: This Question is unanswered, help us to find answer for this one
Check Answer
114.
How can the Heroku deprecation warning be removed from a Rails plugin that has been used?
ActiveSupport::Deprecation.silenced = true
Can be done in production.rb config.plugins = [ :rails_serve_static_assets ] # ONLY load static assets plugin
Both A and B
None of the above
Answer
Correct Answer:
ActiveSupport::Deprecation.silenced = true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
115.
What is TDD is rails3?
TDD directs focus on testing.
TDD directs focus on behavior and specification.
Both A and B
None of them is correct
Answer
Correct Answer:
TDD directs focus on testing.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
116.
Which of these tools are for checking Ruby code styling?
CodeClimate
Brakeman
Rubocop
SimpleCov
Note: This Question is unanswered, help us to find answer for this one
Check Answer
117.
The asset tag helpers do not verify the existence of the assets at the specified locations.
True
False
Note: This Question is unanswered, help us to find answer for this one
Check Answer
118.
Which of the following validations are supported by models?
Presence validation
Length validation
Format validation
Database uniqueness validation
Answer
Correct Answer:
Presence validation
Note: This Question is unanswered, help us to find answer for this one
Check Answer
119.
After executing the following code, what will the value of foo be? foo = 'bar' wom = Proc.new {|foo| foo = 'baz'} wom.call('pling')
"pling"
"bar"
"baz"
Note: This Question is unanswered, help us to find answer for this one
Check Answer
120.
Which of the following will return a User object when used with a model which deals with a table named User?
User.new
User.destroy
User.find
User.save
Note: This Question is unanswered, help us to find answer for this one
Check Answer
121.
Which of the following options will correctly show an image in the HTML ERB template in Rails?
<%= image_tag("logo.png", :alt=>"Sample Logo", :class=>"round" %>
<%= image_tag(:src=>"logo.png", :alt=>"Sample Logo", :class=>"round" %>
<%= image_tag("logo.png", alt=>"Sample Logo", class=>"round" %>
<%= img_tag("logo.png", :alt=>"Sample Logo", :class=>"round" %>
Answer
Correct Answer:
<%= image_tag("logo.png", :alt=>"Sample Logo", :class=>"round" %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
122.
Which of the following validations checks if a passed value is an enumeration and falls in the given range?
validates_associated
validates_inclusion_of
validates_exclusion_of
validates_numericality_of
Answer
Correct Answer:
validates_inclusion_of
Note: This Question is unanswered, help us to find answer for this one
Check Answer
123.
Which of the following will change a Rails 3 app to run in production mode?
rails s -p production
rails s -e production
rails s production
rails s -p PRODUCTION
Answer
Correct Answer:
rails s -e production
Note: This Question is unanswered, help us to find answer for this one
Check Answer
124.
Given below are two statements regarding Rails testing: Statement X: Unit tests are used to test models. Statement Y: Functional tests are used to test controllers. Which of the following statements is true?
Statement X is correct, but statement Y is incorrect.
Statement X is incorrect, but statement Y is correct.
Both statements X and Y are correct.
Both statements X and Y are incorrect.
Answer
Correct Answer:
Both statements X and Y are correct.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
125.
During the deployment of the Rails application through Git, you want certain files to be ignored. Which of the following files performs that operation?
.gitignore
config.ru
Gemfile
Rakefile
Answer
Correct Answer:
.gitignore
Note: This Question is unanswered, help us to find answer for this one
Check Answer
126.
In a Rails application, a Gemfile needs to be modified to make use of sqlite3-ruby gems. Which of the following options will use these gems, as per the new Gemfile?
install bundle Gemfile
bundle install
mate Gemfile
gem bundle install
Answer
Correct Answer:
bundle install
Note: This Question is unanswered, help us to find answer for this one
Check Answer
127.
Which of the following options will create a new Rails application with default templates?
rails new <application _name>
rails create <application_name>
rails server <application_name>
rails generate <application_name>
Answer
Correct Answer:
rails new <application _name>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
128.
If we need to associate one model with many others, what associations should we use?
has_and_belongs_to_many
has_many, belongs_to
has_one, belongs_to
Answer
Correct Answer:
has_many, belongs_to
Note: This Question is unanswered, help us to find answer for this one
Check Answer
129.
Which of the following options will create a many-to-many relation between the 'users' and the 'jobs' tables?
users_jobs
users_many_jobs
many_users_many_jobs
Answer
Correct Answer:
users_jobs
Note: This Question is unanswered, help us to find answer for this one
Check Answer
130.
For the String class, when using #gsub! what are the potential return values?
The string instance
nil
nil or the string instance
Answer
Correct Answer:
nil or the string instance
Note: This Question is unanswered, help us to find answer for this one
Check Answer
131.
What is the purpose of the model in an MVC architecture framework such as Ruby on Rails?
The model houses all the code that relates to data.
The model contains the minimum amount of code to display data.
Methods in the model can be directly accessed in Rails views.
The model performs parsing user requests, data submissions, cookies, sessions and other web browser operations.
Answer
Correct Answer:
The model houses all the code that relates to data.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
132.
Which of the following statements regarding models in Ruby on Rails is correct?
The page HTML is generated by models.
The fetching of data from database is performed by models.
The web requests sent by the browser is handled by models.
The routing configuration is done by models.
Answer
Correct Answer:
The fetching of data from database is performed by models.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
133.
Which of the following actions is fired by default when a new controller is created?
index
run
show
login
Note: This Question is unanswered, help us to find answer for this one
Check Answer
134.
Which of the following options is used to create a form HTML in the erb files?
form_for
create_form
form_do
form
Note: This Question is unanswered, help us to find answer for this one
Check Answer
135.
The =~ operator is used to do inline Regular Expression matching, for instance:
"function" =~ /fun/
"function" =~ /dinosaurs/
What are possible return values for the =~ matcher?
true, false
"fun", nil
1 and 0 only
0 and nil only
nil, 0, and any positive integer
Answer
Correct Answer:
nil, 0, and any positive integer
Note: This Question is unanswered, help us to find answer for this one
Check Answer
136.
Which of the following options will disable the rendering of the view associated with a controller action?
render :layout=>false
render :layout=>nil
render :layout=>disabled
render :layout=>off
Answer
Correct Answer:
render :layout=>false
Note: This Question is unanswered, help us to find answer for this one
Check Answer
137.
What is the output of the following code?
$val = 20
print "Sample Text\n" if $val
20
Sample Text
No output
Syntax error
Answer
Correct Answer:
Sample Text
Note: This Question is unanswered, help us to find answer for this one
Check Answer
138.
If a model called BlogComment is defined, what would its DB table be blog_commentcalled?
blog_comment
blogcomments
blog_comments
Answer
Correct Answer:
blog_comments
Note: This Question is unanswered, help us to find answer for this one
Check Answer
139.
Consider the following information for a User view:
user_path named route with value "/users/"
@user = 1
Now, consider the following code in the HTML erb template:
<%= link_to user_path(@user), "Angel" %>
What will be the HTML output of this code?
a href='/users/1'>Angel</a
a href='Angel'>/users/1</a
a href='/users/1'>/users/1</a
a href='Angel'>Angel</a
Answer
Correct Answer:
a href='/users/1'>Angel</a
Note: This Question is unanswered, help us to find answer for this one
Check Answer
140.
There is a table named Product in a Rails application. The program is required to fetch any 5 rows where the productid is 2. Which of the following is the correct option to perform this action?
Product.find(:productid=>2), :offset=>5
Product.find(:productid=>2), :limit=>5
Product.find(:productid=>2), :only=>5
Answer
Correct Answer:
Product.find(:productid=>2), :limit=>5
Note: This Question is unanswered, help us to find answer for this one
Check Answer
141.
What is the behavior of class variables with subclasses?
Subclasses inherit a default value for the class variable, which can then
be modified for just the subclass.
Class variables are shared between between all classes in the hierarchy.
Class variables are not inherited.
Answer
Correct Answer:
Class variables are shared between between all classes in the hierarchy.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
142.
Which of the following is true about writing tests for a Ruby on Rails application?
Rails semi-automates the process of writing tests. It starts by producing
skeleton test code in the background while models and controllers are
being written.
Running tests in Rails ensures that the code adheres to the desired
functionality even after major code refactoring.
Rails tests can simulate browser requests, and thus test the application's
response without having to test it through a browser.
All of these.
Answer
Correct Answer:
Rails semi-automates the process of writing tests. It starts by producing
skeleton test code in the background while models and controllers are
being written.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
143.
Rails automatically requires certain files in an application. Which of the following files are automatically included without an explicit 'require' being necessary?
All files in lib.
All files in models, views, controllers, and files named rails.rb in lib.
All files in models, views, controllers, and any init.rb in plugins.
Only files explicitly referenced from an initializer in config/initializers.
Answer
Correct Answer:
All files in models, views, controllers, and any init.rb in plugins.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
144.
Which of the following controller actions (by default) are best suited to handle the GET HTTP request?
index
show
create
edit
update
Note: This Question is unanswered, help us to find answer for this one
Check Answer
145.
For the String class, what's the difference between "#slice" and "#slice!"?
None, "#slice" is just an alias for "#slice!".
There is no "#slice!" method in Ruby on Rails.
"#slice" returns a new object, "#slice!" destructively updates — mutates — the object's value.
Answer
Correct Answer:
"#slice" returns a new object, "#slice!" destructively updates — mutates — the object's value.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
146.
What is output of following statements?
1) "".nil? == "".empty? && "".blank? == "".empty?
2) !"".nil? == "".empty? && "".blank? == "".empty?
3) nil.nil? == nil.empty? && nil.blank? == nil.empty?
4) !"".blank? == "".present?
5) "".any? == !"".empty?
6) " ".blank? == " ".empty?
1) false 2) true 3) NoMethodError: undefined method `empty?' for
nil:NilClass 4) true 5) NoMethodError: undefined method `any?' for "":String
6) false
1) false 2) NoMethodError: undefined method `empty?' for "":String 3) true
4) true 5) NoMethodError: undefined method `any?' for "":String 6) false
1) false 2) true 3) true 4) true 5) false 6) false
1) false 2) true 3) false 4) true 5) true 6) false
Answer
Correct Answer:
1) false 2) true 3) false 4) true 5) true 6) false
Note: This Question is unanswered, help us to find answer for this one
Check Answer
147.
Using ERB for views, what filename should be given to a partial called 'login'?
partial_login.e
_login.html.e
login.html.e
Answer
Correct Answer:
_login.html.e
Note: This Question is unanswered, help us to find answer for this one
Check Answer
148.
Which of the following validations in Rails checks for null fields?
validates_presence_of
validates_length_of
validates_confirmation_of
validates_uniqueness_of
Answer
Correct Answer:
validates_presence_of
Note: This Question is unanswered, help us to find answer for this one
Check Answer
149.
What does the 4xx series of HTTP errors represent?
They are intended for cases in which the server seems to have encountered an error.
They are intended for cases in which the client seems to have encountered an error.
They indicate that further action needs to be taken by the user agent in order to fulfill the request.
They indicate that no further action can be taken by the user agent.
Answer
Correct Answer:
They are intended for cases in which the client seems to have encountered an error.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
150.
How can a partial called "cart" be rendered from a controller called "ProductsController", assuming the partial is in a directory called "shared"?
render :partial => 'shared/cart'
partial 'shared/cart'
render 'cart'
Answer
Correct Answer:
render :partial => 'shared/cart'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
151.
Which of the following correctly handles the currency field?
A) add_column :items, :price, :decimal, :precision => 8, :scale => 2
B) add_money :items, :price, currency: { present: false }
A
B
Both A and B are correct.
Both A and B are incorrect.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
152.
What is the convention for methods which end with a question mark?
e.g. #all?, #kind_of?, directory?
They should always require arguments.
They should always return a boolean value.
They should always report a value of the object they're being called on.
Answer
Correct Answer:
They should always return a boolean value.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
153.
In a Rails application, the developmental and production configuration are stored in the:
config/environments folder
public folder
spec folder
task folder
Answer
Correct Answer:
config/environments folder
Note: This Question is unanswered, help us to find answer for this one
Check Answer
154.
Which of the following is not a built-in Rails caching strategy used to reduce database calls?
Page Caching
Fragment Caching
Object Caching
Query Caching
Answer
Correct Answer:
Object Caching
Note: This Question is unanswered, help us to find answer for this one
Check Answer
155.
Select all incorrect statements regarding the Ruby Version Manager (RVM):
RVM is a command-line tool which allows developers to easily install,
manage, and work with multiple Ruby environments from interpreters to
sets of gems.
RVM provides a revision control tool to maintain current and historical
versions of files such as source code, web pages, and documentation.
Test suites, rake tasks, benchmarks and gem commands can be run
against multiple Ruby versions at the same time with RVM.
RVM cannot automate the installation and maintenance of gems, it has to
be done manually.
Answer
Correct Answer:
RVM provides a revision control tool to maintain current and historical
versions of files such as source code, web pages, and documentation.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
156.
When a new controller named "admin2" is created, the JS and the CSS files are created in:
controllers
helpers
assets
views
Note: This Question is unanswered, help us to find answer for this one
Check Answer
157.
Which of the following is not true about log levels in Ruby on Rails?
The available log levels are: :debug, :info, :warn, :error, and :fatal,
corresponding to the log level numbers from 1 up to 5 respectively.
To check the current log level, the Rails.logger.level method has to be
called.
By default, each log is created under Rails.root/log/ and the log file name
is environment_name.log.
The default Rails log level is error in production mode and debug in
development and test mode.
Answer
Correct Answer:
The available log levels are: :debug, :info, :warn, :error, and :fatal,
corresponding to the log level numbers from 1 up to 5 respectively.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
158.
With the two models Hive and Bee; when creating a belongs_to association from the Bee model to Hive, what is the foreign key generated on Bee?
hive_id
hives_id
ee_id
Note: This Question is unanswered, help us to find answer for this one
Check Answer
159.
What does REST stand for?
Ruby Enclosed Standard Templating
Resource Standard Transfer
REasonable Standards Testing
REpresentational State Transfer
Rights Enabled Safety Tunnel
Answer
Correct Answer:
REpresentational State Transfer
Note: This Question is unanswered, help us to find answer for this one
Check Answer
160.
Users who are new to MVC design often ask how to query data from Views. Is this possible? And if so, is this a good idea?
It is not possible, because ActiveRecord queries cannot be made from
Views.
It is not possible, because Controllers do not provide enough information
to the Views.
It is possible, but it is a bad idea because Views should only be
responsible for displaying objects passed to them.
Answer
Correct Answer:
It is possible, but it is a bad idea because Views should only be
responsible for displaying objects passed to them.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
161.
What is the Singleton design pattern?
A class for which there is only ever one instance.
A single feature application, intended to enhance usability by keeping
things simple.
A class which is never instanced, but acts as a container for methods
which are used by it's subclasses.
Answer
Correct Answer:
A class for which there is only ever one instance.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
162.
Which of the following statements is incorrect?
Rails does not support ODBC connectivity.
Rails can rollback database changes in development mode.
Rails can work and connect with multiple databases.
Rails database information is stored in the database.yml file.
Answer
Correct Answer:
Rails does not support ODBC connectivity.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
163.
Which of the following serves as a structural skeleton for all HTML pages created?
application.html.erb
default.html.erb
index.html.erb
layout.html.erb
Answer
Correct Answer:
application.html.erb
Note: This Question is unanswered, help us to find answer for this one
Check Answer
164.
If a controller is named "Users", what would its helpers module be called?
UsersHelper
UserControllerHelper
UserHelp
Answer
Correct Answer:
UsersHelper
Note: This Question is unanswered, help us to find answer for this one
Check Answer
165.
Consider the following code snippet:
def index
render
end
The corresponding index.html.erb view is as following:
<html>
<head>
<title>Ruby on Rails sample application | <%=@title%></title>
</head>
<body></body>
</html>
Which of the following options is correct?
The application will give an exception as @title variable is not defined in
the controller.
The HTML page will render with the title: Ruby on Rails sample
application | <%=@title%>.
The HTML page will render with the title: Ruby on Rails sample
application |.
The HTML page will render with the title: Ruby on Rails sample
application.
Answer
Correct Answer:
The application will give an exception as @title variable is not defined in
the controller.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
166.
Which of the following commands will test a particular test case, given that the tests are contained in the file test/unit/demo_test.rb, and the particular test case is test_one?
$ ruby -Itest test/unit/demo_test.rb -n test_one
$ ruby -Itest test/unit/demo_test.rb -a test_one
$ ruby -Itest test/unit/demo_test.rb test_one
$ ruby -Itest test/unit/demo_test.rb -t test_one
Answer
Correct Answer:
$ ruby -Itest test/unit/demo_test.rb -a test_one
Note: This Question is unanswered, help us to find answer for this one
Check Answer
167.
Which of the following will disable browser page caching in Rails?
expire_page(:controller => 'products', :action => 'index')
expire_fragment(:controller => 'products', :action => 'index')
expire_page_fragment('all_available_products')
expire_fragment('all_available_products')
Answer
Correct Answer:
expire_page(:controller => 'products', :action => 'index')
Note: This Question is unanswered, help us to find answer for this one
Check Answer
168.
In a Rails Migration, which of the following will make a column unique, and then have it indexed?
add_index :table_name, :column_name, :unique => true
add_index :unique => true ,:table_name, :column_name
add_index :table_name, [:column_name_a, :unique => true ,:column_name_b], :unique => true
None of these
Answer
Correct Answer:
add_index :table_name, :column_name, :unique => true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
169.
If a float is added to an integer, what is the class of the resulting number? i.e. 1.0 + 2
Integer
Float
BigDecimal
Note: This Question is unanswered, help us to find answer for this one
Check Answer
170.
In order to enable locking on a table, which of the following columns is added?
lock_version column
identity column
primary key column
lock_optimistic column
Answer
Correct Answer:
lock_version column
Note: This Question is unanswered, help us to find answer for this one
Check Answer
171.
Which is the best way to add a page-specific JavaScript code in a Rails
3 app?
<%= f.radio_button :rating, 'positive', :onclick => "$('some_div').show();"
%>
<% content_for :head do %> <script type="text/javascript"> <%=
render :partial => "my_view_javascript" </script> <% end %> Then in layout
file <head> ... <%= yield :head %> </head>
In the application_helper.rb file: def include_javascript (file) s = " <script
type=\"text/javascript\">" + render(:file => file) + "</script>"
content_for(:head, raw(s)) end Then in your particular view (app/views/
books/index.html.erb in this example) <% include_javascript 'books/
index.js' %>
In the controller: def get_script render :file => 'app/assessts/javascripts/' +
params[:name] + '.js' end def get_page @script = '/' +
params[:script_name] + '.js?body=1' render page end In View <script
type="text/javascript",:src => @script>
None of these
Answer
Correct Answer:
None of these
Note: This Question is unanswered, help us to find answer for this one
Check Answer
172.
Which of the following is the correct syntax for an input field of radio buttons in form_for?
<%= f.radio_button :contactmethod, 'sms' %>
<%= f.radio_button_tag :contactmethod, 'sms' %>
<%= radio_button_tag :contactmethod, 'sms' %>
<%= f.radio_button "contactmethod", 'sms' %>
Answer
Correct Answer:
<%= f.radio_button :contactmethod, 'sms' %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
173.
Which of the following is the correct way to rollback a migration?
A migration cannot be rollbacked.
rake db:rollback STEP=N (N is the migration number to be rollbacked)
rake db:migrate:reset: (N) (N is the migration number to be rollbacked)
rake db:rollback migration=N (N is the migration number to be rollbacked)
Answer
Correct Answer:
rake db:rollback STEP=N (N is the migration number to be rollbacked)
Note: This Question is unanswered, help us to find answer for this one
Check Answer
174.
Which of the following methods is used to check whether an object is valid or invalid?
.valid? and .invalid?
valid() and invalid()
isvalid and isinvalid
Answer
Correct Answer:
.valid? and .invalid?
Note: This Question is unanswered, help us to find answer for this one
Check Answer
175.
What is the difference between :dependent => :destroy and :dependent => :delete_all in Rails?
There is no difference between the two; :dependent => :destroy
and :dependent => :delete_all are semantically equivalent.
In :destroy, associated objects are destroyed alongside the object by
calling their :destroy method, while in :delete_all, they are destroyed
immediately, without calling their :destroy method.
In :delete_all, associated objects are destroyed alongside the object by
calling their :destroy method, while in :destroy, they are destroyed
immediately, without calling their individual :destroy methods.
None of these.
Answer
Correct Answer:
In :destroy, associated objects are destroyed alongside the object by
calling their :destroy method, while in :delete_all, they are destroyed
immediately, without calling their :destroy method.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
176.
Suppose a model is created as follows:
rails generate model Sales
rake db:migrate
What would be the best way to completely undo these changes, assuming
nothing else has changed in the meantime?
rails reset models; rake db:rollback
rails destroy model Sales; rake db:rollback
rake db:rollback; rails rollback model Sales
rake db:rollback; rails destroy model Sales
Answer
Correct Answer:
rake db:rollback; rails destroy model Sales
Note: This Question is unanswered, help us to find answer for this one
Check Answer
177.
What is the output of the following code?
puts "aeiou".sub(/[aeiou]/, '*')
*
*****
*eiou
nil
Note: This Question is unanswered, help us to find answer for this one
Check Answer
178.
What declaration would you use to set the layout for a controller?
layout 'new_layout'
set_layout 'new_layout'
@layout = 'new_layout'
Answer
Correct Answer:
layout 'new_layout'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
179.
Which of the following options, when passed as arguments, skips a particular validation?
:validate => skip
:validate => off
:validate => disable
:validate => false
Answer
Correct Answer:
:validate => false
Note: This Question is unanswered, help us to find answer for this one
Check Answer
180.
Which of the following is the default way that Rails seeds data for tests?
Data Migrations
Factories
Fixture Factories
Fixtures
Note: This Question is unanswered, help us to find answer for this one
Check Answer
181.
Which of the following is the correct way to skip ActiveRecords in Rails 3?
ActiveRecords cannot be skipped.
Use option -O while generating application template.
Use option -SKIP_AR while generating the application template.
Add new line SKIP: ACTIVERECORD in config.generators.
Answer
Correct Answer:
Add new line SKIP: ACTIVERECORD in config.generators.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
182.
Choose the best way to implement sessions in Rails 3:
A) Using CookieStore
B) By creating a session table and setting config/initializers/
session_store.rb with
Rails.application.config.session_store :active_record_store
C) By setting config/initializers/session_store.rb with
Rails.application.config.session_store :active_record_store only
A
B
C
B and C
Note: This Question is unanswered, help us to find answer for this one
Check Answer
183.
Given below are two statements regarding the Ruby programming
language:
Statement X: "redo" restarts an iteration of the most internal loop, without
checking loop condition.
Statement Y: "retry" restarts the invocation of an iterator call. Also,
arguments to the iterator are re-evaluated.
Which of the following options is correct?
Statement X is correct, but statement Y is incorrect.
Statement X is incorrect, but statement Y is correct.
Both statements are correct.
Both statements are incorrect.
Answer
Correct Answer:
Statement X is incorrect, but statement Y is correct.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
184.
Which of the following commands will clear out sample users from the development database?
rake db:migrate
rake db:reset
rake db:rollback
Answer
Correct Answer:
rake db:reset
Note: This Question is unanswered, help us to find answer for this one
Check Answer
185.
Is an AJAX call synchronous or asynchronous?
Asynchronous
Synchronous
Either; it is configurable
Answer
Correct Answer:
Either; it is configurable
Note: This Question is unanswered, help us to find answer for this one
Check Answer
186.
Which of the following assertions are used in testing views?
assert_valid
assert_select_email
assert_select_encoded
css_select
Answer
Correct Answer:
assert_select_email
Note: This Question is unanswered, help us to find answer for this one
Check Answer
187.
What is green-threading?
A design pattern where a fixed-size pool of threads is shared around a
program.
When threads are emulated by a virtual machine or interpreter.
Where programs are run across multiple CPUs.
Answer
Correct Answer:
When threads are emulated by a virtual machine or interpreter.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
188.
If a method #decoupage(n) is described as O(n^2), what does that mean?
The fewest number of operations it will perform is n*n.
The worst case run time is proportional to the size of the square of the method's input.
The method operates by squaring the input.
The return value for the method will be the length of the input squared.
Answer
Correct Answer:
The worst case run time is proportional to the size of the square of the method's input.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
189.
Which of the following replaced the Prototype JavaScript library in Ruby on Rails as the default JavaScript library?
jQuery
Ajax
Script.aculo.us
ajax-li
Note: This Question is unanswered, help us to find answer for this one
Check Answer
190.
What component of Rails are tested with unit tests?
Models
Controllers
View helpers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
191.
What exception cannot be handled with the rescue_from method in the
application controller?
e.g
class ApplicationControllers < ActionController::Base
rescue_from Exception, with: error_handler
..........
end
Server errors
Record not found (404)
Routing errors
All of these
Answer
Correct Answer:
All of these
Note: This Question is unanswered, help us to find answer for this one
Check Answer
192.
Which gem is used to install a debugger in Rails 3?
gem 'ruby-debug1'
gem "ruby-debug19"
gem "debugger19"
gem "ruby-debugger"
Answer
Correct Answer:
gem "ruby-debug19"
Note: This Question is unanswered, help us to find answer for this one
Check Answer
193.
What is the output of the following code in Ruby?
x= "A" + "B"
puts x
y= "C" << "D"
puts y
AB CD
AB C
AB D
AB DC
Note: This Question is unanswered, help us to find answer for this one
Check Answer
194.
Which of the following items are stored in the models subdirectory?
helper classes
database classes
HTML layout templates
Config files
Answer
Correct Answer:
database classes
Note: This Question is unanswered, help us to find answer for this one
Check Answer
195.
Which part of the MVC stack does ERB or HAML typically participate in?
Class
Controller
Model
Module
View
Note: This Question is unanswered, help us to find answer for this one
Check Answer
196.
Given the following code, where is the "party!" method available?
module PartyAnimal
def self.party!
puts "Hard! Better! Faster! Stronger!"
end
end
class Person
include PartyAnimal
end
PartyAnimal.party!
Person.party!
Person.new.party!
Both PartyAnimal.party! and Person.party!
None of these
Answer
Correct Answer:
PartyAnimal.party!
Note: This Question is unanswered, help us to find answer for this one
Check Answer
197.
where we use attr_accessor and attr_accessible in rails ?
controller
helper
model
view
Note: This Question is unanswered, help us to find answer for this one
Check Answer
198.
What is the recommended Rails way to iterate over records for display in a view?
Implicitly loop over a set of records, and send the partial being rendered a :collection.
Use each to explicitly loop over a set of records.
Use for to fetch individual records explicitly in a loop.
Answer
Correct Answer:
Implicitly loop over a set of records, and send the partial being rendered a :collection.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
199.
What is best way to create primary key as a string field instead of integer in rails.
when creating a new table don't add primary key using this create_table
users, :id => false do |t| t.string :id, :null => false ...... end execute("ALTER
TABLE users ADD PRIMARY KEY (id)") if not using id as primary key then
in users model add the following line class User < ActiveRecord::Base
self.primary_key = "column_name" .... end
you can add a key to column name to make it primary create_table
users :id => false do |t| t.string :column_name, :primary => true end
Answer
Correct Answer:
when creating a new table don't add primary key using this create_table
users, :id => false do |t| t.string :id, :null => false ...... end execute("ALTER
TABLE users ADD PRIMARY KEY (id)") if not using id as primary key then
in users model add the following line class User < ActiveRecord::Base
self.primary_key = "column_name" .... end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
200.
Which of the following is the correct way to know the Rails root directory path?
RAILS_ROOT
Rails.root
Rails.root.show
Rails.show.root
Answer
Correct Answer:
Rails.root
Note: This Question is unanswered, help us to find answer for this one
Check Answer
201.
What is difference between "has_one" and "belong_to"?
"has_one" should be used in a model whose table have foreign keys while
"belong_to" is used with an associated table.
"belong_to" should be used in a model whose table have foreign keys
while "has_one" is used with an associated table.
The two are interchangeable.
None of these.
Answer
Correct Answer:
"belong_to" should be used in a model whose table have foreign keys
while "has_one" is used with an associated table.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
202.
What is the output of the following Ruby code?
puts "The multiplication output of 10,10,2 is #{10*10*2}"
200.
The multiplication output of 10,10,2 is #{10*10*2}.
The multiplication output of 10,10,2 is 200.
The code will give a syntax error.
Answer
Correct Answer:
The multiplication output of 10,10,2 is 200.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
203.
Which of the following choices will write routes for the API versioning scenario described below?
/api/users returns a 301 to /api/v2/users
/api/v1/users returns a 200 of users index at version 1
/api/v3/users returns a 301 to /api/v2/users
/api/asdf/users returns a 301 to /api/v2/users
namespace :api do namespace :v1 do resources :users end
namespace :v2 do resources :users end match 'v:api/*path', :to =>
redirect("/api/v2/%{path}") match '*path', :to => redirect("/api/v2/%{path}")
end
namespace :api do resources :users end namespace :v2 do
resources :users end match 'v:api/*path', :to => redirect("/api/v1/%{path}")
match '*path', :to => redirect("/api/v1/%{path}") end
namespace :api do scope :module => :v3, ¤t_api_routes
namespace :v3, ¤t_api_routes namespace :v2, ¤t_api_routes
namespace :v1, ¤t_api_routes match ":api/*path", :to => redirect("/
api/v3/%{path}") end
None of these
Answer
Correct Answer:
namespace :api do namespace :v1 do resources :users end
namespace :v2 do resources :users end match 'v:api/*path', :to =>
redirect("/api/v2/%{path}") match '*path', :to => redirect("/api/v2/%{path}")
end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
204.
Which of the following code samples will get the index of |page| inside of a loop?
<% @images.each.do |page,index| %> <% end %>
<% @images.each_with_index do |page, index| %> <% end %>
<% @images.collect.each.at_index do |page, index| %> <% end %>
None of these
Answer
Correct Answer:
<% @images.each_with_index do |page, index| %> <% end %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
205.
What is the difference between _url and _path while being used in routes?
_url is absolute while _path is relative.
_path is relative while _path is absolute.
_path is used in controllers while _url is used in views.
_path is used in views while _url is used in controllers.
Answer
Correct Answer:
_url is absolute while _path is relative.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
206.
When using full-page caching, what happens when an incoming request matches a page in the cache?
The web-server serves the file directly from disk, bypassing Rails.
Rails checks to see if there is a cached page on disk and passes it onto the server.
Rails checks its in-memory cache and passes the page onto the server.
Answer
Correct Answer:
Rails checks to see if there is a cached page on disk and passes it onto the server.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
207.
What is the output of the following code? test*5
type casting error
test5
5
testtesttesttesttest
Answer
Correct Answer:
testtesttesttesttest
Note: This Question is unanswered, help us to find answer for this one
Check Answer
208.
In a has_many association, what is the difference between build and new?
// user.rb
has_many :posts
// post.rb
belongs_to :user
'new' sets the foreign key while 'build' does not.
'build' sets the foreign key while 'new' does not.
'build' sets the foreign key and adds it to the collection.
'new' sets the foreign key and adds it to the collection.
Answer
Correct Answer:
'build' sets the foreign key and adds it to the collection.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
209.
Which of the following HTML template languages are supported by Ruby?
Embedded Ruby
HAML
Mustache
Razor
Answer
Correct Answer:
Embedded Ruby
Note: This Question is unanswered, help us to find answer for this one
Check Answer
210.
Which of the following commands adds the data model info to the model file?
bundle install
generate model
annotate
Rails server
Answer
Correct Answer:
generate model
Note: This Question is unanswered, help us to find answer for this one
Check Answer
211.
How can a value be stored so that it's shared across an entire request (i.e. make it accessible in controllers, views and models)?
Put it in a global variable.
Create a Singleton and stored it in a class variable.
Store it in a thread locally.
Answer
Correct Answer:
Store it in a thread locally.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
212.
In the case of Rails application performance optimization, select all valid ways to do assets compilation:
Running the rake task with the assets:precompile parameter when CSS and JavaScript files are updated.
Set a true value for the config.assets.compile parameter in the config/
environments/production.rb file.
Implementing the Rails asset pipeline feature to minify JavaScript & CSS
assets.
All of these.
Answer
Correct Answer:
All of these.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
213.
Which of the following options in the Ruby on Rails MVC architecture handles the dynamic data and the classes with the database?
Models
Controllers
Helpers
Views
Note: This Question is unanswered, help us to find answer for this one
Check Answer
214.
With an XHTML document, how can quirks mode be triggered in Internet Explorer?
Define a doc-type.
Insert a proprietory meta tag into the document head.
Turn it on explicitly with a JavaScript property i.e. window.quirksMode = true.
Answer
Correct Answer:
Define a doc-type.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
215.
Which of the following are Rails specific assertions to the test/unit framework?
assert_valid
assert_no_difference
assert_recognizes
assert_send
Answer
Correct Answer:
assert_no_difference
Note: This Question is unanswered, help us to find answer for this one
Check Answer
216.
Which of the following options will find a row from the Users table having id = 1?
Users.find(1)
Users.find :first, :conditions => ['id = ?', 1]
Users.find_by_id(1)
Users.with_id_1
Answer
Correct Answer:
Users.find(1)
Note: This Question is unanswered, help us to find answer for this one
Check Answer
217. True or False? Proc is a nameless function, an anonymous method.
False
True
Note: This Question is unanswered, help us to find answer for this one
Check Answer
218. The 'rails c' command...
Returns error, because command does not exist
Starts rails console
Creates a new rails application
Answer
Correct Answer:
Starts rails console
Note: This Question is unanswered, help us to find answer for this one
Check Answer
219. How to print the list of available generators?
rails generate
rails generators
rails --generators
rails --list-generators
Answer
Correct Answer:
rails generate
Note: This Question is unanswered, help us to find answer for this one
Check Answer
220. After importing from GitHub our Ruby on Rails project via the terminal using "git clone ...", what is required to do to ensure we can start working on our project?
Nothing, git clone does everything for us
Navigate to our project folder, bundle install, rake db:create
Navigate to our project folder, bundle install
Navigate to our project folder, bundle install, rake db:create, rake db:migrate
Navigate to our project folder, rake db:create
Answer
Correct Answer:
Navigate to our project folder, bundle install, rake db:create, rake db:migrate
Note: This Question is unanswered, help us to find answer for this one
Check Answer
221. What is the right command to see the list of available tasks?
rake -T or rake --task
rake -t or rake --tasks
rake --all-tasks
rake -T or rake --tasks
rake -L or rake --list
Answer
Correct Answer:
rake -T or rake --tasks
Note: This Question is unanswered, help us to find answer for this one
Check Answer
222. Let we have declared a Student class. What is output of this statement? Student.class
null
Uninitialized constant Student
nil
Object
class
Note: This Question is unanswered, help us to find answer for this one
Check Answer
223. Which of these statements will utilize the gem named 'mygem
require 'mygem'
instantiate 'mygem'
sudo 'mygem'
Answer
Correct Answer:
require 'mygem'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
224. Where to add business logic? a) Model b) Controller c) View
b
a
c
Note: This Question is unanswered, help us to find answer for this one
Check Answer
225. Where declare validations to a application?
Presenter
Model
Helper
Controller
View
Note: This Question is unanswered, help us to find answer for this one
Check Answer
226. If @user is not null, the expression <%= @user.present? ? "Yes" : "No" %> return:
null
nil
Yes
No
Exception
Note: This Question is unanswered, help us to find answer for this one
Check Answer
227. What is the difference between Post.find(3) and Post.find_by_id(3) ?
find_by will not throw the exception if post with an id=3 will not be found
find_by_id method doesn't even exists in Rails!
there is no difference, "find" is an alias for "find_by_id" method
find_by_id will return collection instead of single record
Answer
Correct Answer:
find_by will not throw the exception if post with an id=3 will not be found
Note: This Question is unanswered, help us to find answer for this one
Check Answer
228. a = (1..3).reduce(-6){ |i,x| x + i } puts a
4
-6
6
-2
0
Note: This Question is unanswered, help us to find answer for this one
Check Answer
229. [1,2,3,5,8,13].include? '8'
false
true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
230. The databases supported by ActiveRecord without any other gem are:
Sqlite, MySQL, PostgreSQL, Oracle, MongoDB
Sqlite, MySQL, PostgreSQL, Oracle
Sqlite, PostgreSQL
Sqlite, MySQL, PostgreSQL, MongoDB
Sqlite, MySQL, PostgreSQL
Answer
Correct Answer:
Sqlite, MySQL, PostgreSQL
Note: This Question is unanswered, help us to find answer for this one
Check Answer
231. What is the purpose of config.ru file?
It's the file where are defined the gems used
It's the basic Rails configuration file
It's not used in Ruby on Rails applications, it's here only for historic reasons
It's the Rack configuration file, a module webserver interface
Answer
Correct Answer:
It's the Rack configuration file, a module webserver interface
Note: This Question is unanswered, help us to find answer for this one
Check Answer
232. The best practice says:
Fat models, thin controllers and views
Fat views, thin models and controllers
Fat controllers, thin models and views
Answer
Correct Answer:
Fat models, thin controllers and views
Note: This Question is unanswered, help us to find answer for this one
Check Answer
233. How you can load your database with seeded data
rake db:seed
rake db:seed:data
Answer
Correct Answer:
rake db:seed
Note: This Question is unanswered, help us to find answer for this one
Check Answer
234. How to add a coffeescript file, follow the Asset Pipeline rules, somewhere in the "view"?
<%= javascript_include_tag "javascript-file-name" %>
Answer
Correct Answer:
<%= javascript_include_tag "javascript-file-name" %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
235. Where you define the gems used in a Ruby on Rails application?
app/config/Gemfile
config/Gemfile
Gemfile
GEMFILE
Note: This Question is unanswered, help us to find answer for this one
Check Answer
236. I already have a project running locally on port 3000. How can I start another project on port 3001?
rails s on 3001
server 3001
rails s -p 3001
rails 3001
rails server -r 3001
Answer
Correct Answer:
rails s -p 3001
Note: This Question is unanswered, help us to find answer for this one
Check Answer
237. True or False. Using "rails g scaffold card", this will create a Card controller, model and views.
True
False
Note: This Question is unanswered, help us to find answer for this one
Check Answer
238. What is the output of following? 1==(0||1)
true
false
Note: This Question is unanswered, help us to find answer for this one
Check Answer
239. Which of the following is not a standard validates option?
:unique
:confirmation
:exclusion
:presence
Note: This Question is unanswered, help us to find answer for this one
Check Answer
240. The index_by method is...
not a method in standard Ruby on Rails
an ActiveRecord migration helper method for creating database table indexes
a standard ruby method on Array for creating a Hash index from an Array with keys computed by the block argument
an ActiveRecord helper method for fetching results in groups of size specified by the argument
a Ruby on Rails method to create a Hash from an Array with keys computed by the block argument
Answer
Correct Answer:
a Ruby on Rails method to create a Hash from an Array with keys computed by the block argument
Note: This Question is unanswered, help us to find answer for this one
Check Answer
241. Which of the following will return true?
all of these
false.class.superclass == Object
true.class == Boolean
true.is_a? Boolean
Answer
Correct Answer:
false.class.superclass == Object
Note: This Question is unanswered, help us to find answer for this one
Check Answer
242. Initialize method is always:
private
default
public
protected
Note: This Question is unanswered, help us to find answer for this one
Check Answer
243. how Date.today differs from Date.current?
with Date.today you’ll have a system date plus Rails’ time zone applied.
with Date.today you’ll have a system date
Answer
Correct Answer:
with Date.today you’ll have a system date
Note: This Question is unanswered, help us to find answer for this one
Check Answer
244. What is Strong Parameters in rails 4 ?
This makes Action Controller parameters forbidden to be used in Active Model mass assignment without whitelisted.
It provides an interface for protecting attributes from end-user assignment.
It validates attributes from end-user assignment.
Answer
Correct Answer:
It provides an interface for protecting attributes from end-user assignment.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
245. To establish an association from a Post model to another Post model (say if one post is in response to another and there is a parent_post_id column on the posts table), you would add the following to the Post model:
belongs_to :post, :foreign_key => 'parent_post_id'
has_one :parent_post_id, :class_name => 'Post'
has_many :parent_posts, :foreign_key => 'parent_post_id'
has_one :parent_post, :class_name => 'Post'
belongs_to :parent_post, :class_name => 'Post'
Answer
Correct Answer:
belongs_to :parent_post, :class_name => 'Post'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
246. What is the output of the following? a = (1 <=> 2) b = (1 <=> 1.0) c = (b <=> a) puts c
2
FALSE
1
0
Note: This Question is unanswered, help us to find answer for this one
Check Answer
247. Which of the following is a built-in feature of ActiveRecord
Stored procedures
Writeonly records
Enums
Materialized views
Event triggers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
248. We have given: str = 'abcdef' Which of the following will return the string 'def'? 1) str[0,-3] 2) str[-3,3] 3) str[4,3] 4) str['def']
2
2 and 4
1 and 2
1
Note: This Question is unanswered, help us to find answer for this one
Check Answer
249. Which of the following are NOT Ruby keywords? 1) alias 2) yield 3) defined? 4) include?
3
2 and 3
1 and 2
4
Note: This Question is unanswered, help us to find answer for this one
Check Answer
250. Which of the following will return false?
All of these
(1...5) === 5
123 == 123.0
(1..10) != 1
Answer
Correct Answer:
(1...5) === 5
Note: This Question is unanswered, help us to find answer for this one
Check Answer
251. Choose the correct result p a = 1, a = 2
"12"
1
[1,2]
1 //line break// 2
2
Answer
Correct Answer:
1 //line break// 2
Note: This Question is unanswered, help us to find answer for this one
Check Answer
252. Which one IS NOT an application server:
Thin
Ebb
Unicorn
Rainbows
Tomahawk
Note: This Question is unanswered, help us to find answer for this one
Check Answer
253. Given the following code: ; module Wheeled; end ; class Vehicle; end ; class Car < Vehicle ; include Wheeled ; end ; What is the value of this expression: Car.new.kind_of? Wheeled
false
no value (raises ArgumentError)
true
nil
Vehicle
Note: This Question is unanswered, help us to find answer for this one
Check Answer
254. If your controller gets an action that it will render a template for, and you need to add a flash notice to the page, you'd use:
flash.notice(notice_message)
flash[:notice] = notice_message
flash.now.notice(notice_message)
flash.now[:notice] = notice_message
flash = notice_message
Answer
Correct Answer:
flash.now[:notice] = notice_message
Note: This Question is unanswered, help us to find answer for this one
Check Answer
255. Output of the following ? person1 = 'Tim' person2 = person1 person1[0] = 'J' puts person1 puts person2
Jim Jim
Tim Tim
Tim Jim
Jim Tim
Note: This Question is unanswered, help us to find answer for this one
Check Answer
256. You've got a form, and when the user submits invalid data, you simply show them an error page (no redirect). In the controller, to show the general error on the rendered page, you would add:
In controller: flash.now[:error] = message
At the top of page: <%= message %>
In controller: flash.now.error = message
In controller: flash.error = message
In controller: flash[:error] = message
Answer
Correct Answer:
In controller: flash.now[:error] = message
Note: This Question is unanswered, help us to find answer for this one
Check Answer
257. Counter caches can be used for:
Caching the results of Model.count queries to bypass hitting the database
Saving space in the database by consolidating count query results
Flushing caches when models are modified
Caching arbitrary query results (often of the form Model.count)
Caching the counts of associations to avoid unnecessary Model.count queries
Answer
Correct Answer:
Caching the counts of associations to avoid unnecessary Model.count queries
Note: This Question is unanswered, help us to find answer for this one
Check Answer
258. Handling an AJAX request in controller, which of the following redirects to google?
redirect_to 'http://google.com'
All of these
render js: "window.location = 'http://google.com'"
redirect_javascript "http://google.com"
Answer
Correct Answer:
render js: "window.location = 'http://google.com'"
Note: This Question is unanswered, help us to find answer for this one
Check Answer
259. If you're using the standard Rails RESTful routes, then which of the following actions map to the url, '/posts'?
posts#create or posts#index
posts#update or posts#index or posts#edit
posts#all or posts#index
posts#destroy_all or posts#index
posts#show or posts#index or posts#create
Answer
Correct Answer:
posts#create or posts#index
Note: This Question is unanswered, help us to find answer for this one
Check Answer
260. In development mode (config.assets.digest = false), if a file exists in app/assets/javascript/hello.js, which link will show that file ?
localhost:3000/assets/hello.js
localhost:3000/hello.js
localhost:3000/assets/application.js
localhost:3000/assets/javascript/hello.js
Answer
Correct Answer:
localhost:3000/assets/hello.js
Note: This Question is unanswered, help us to find answer for this one
Check Answer
261. Determine the value of the variable a, b and c after the execution of the following code. a, b, c = 1, 2, 3, 4
a = 1 b = [2,3] c = 4
a = 1 b = 2 c = 3
a = 1 b = 2 c = [3, 4]
a = [1, 2] b = 3 c = 4
Answer
Correct Answer:
a = 1 b = 2 c = 3
Note: This Question is unanswered, help us to find answer for this one
Check Answer
262. Which is not a valid callback?
before_destroy
after_save
after_delete
before_update
after_validation
Answer
Correct Answer:
after_delete
Note: This Question is unanswered, help us to find answer for this one
Check Answer
263. In The Author Model, how do you create a nested association between Authors and Blogs?
has_many :blogs
has_many :blog
:author has_many :blog
:blog has_many :author
has_many :blogs, :through => :author
Answer
Correct Answer:
has_many :blogs
Note: This Question is unanswered, help us to find answer for this one
Check Answer
264. What's an equivalent way of performing the following (h is a Hash): h.each { |k,v| h.delete k if k.nil? }
The original will result in a warning: multiple values for a block parameter
h.keys.compact!
h.delete_if { |k,v| k.nil? }
h.compact!
The original will raise a NoMethodError
Answer
Correct Answer:
h.delete_if { |k,v| k.nil? }
Note: This Question is unanswered, help us to find answer for this one
Check Answer
265. Which of the following are valid objects of class Integer or one of its subclasses? 1) -123 2) 0xFF 3) 123_456_789 4) 123456789123456789123456789123456789
1 and 4
4
1
All of the above
Answer
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Check Answer
266. If a method is protected:
It may be called by any instance of the defining class or its subclasses
It may be called only by the instance of its subclasses
It may not be called by any instances.
It may be called only by the instance of defining class
Answer
Correct Answer:
It may be called by any instance of the defining class or its subclasses
Note: This Question is unanswered, help us to find answer for this one
Check Answer
267. The Controller in Post#create: what is the "best practice" action when the user submits an invalid form?
render action: 'new', alert: 'The Post is incomplete or invalid.'
render action: 'create', alert: 'The Post is incomplete or invalid.'
render action: 'update', alert: 'The Post is incomplete or invalid.'
redirect_to 'new', notice: 'The Post is incomplete or invalid'
redirect_to @post, notice: 'The Post is incomplete or invalid'
Answer
Correct Answer:
render action: 'new', alert: 'The Post is incomplete or invalid.'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
268. Which HTTP method is used by default when clicking a button defined using the ActionView helper method 'button_to'?
delete
post
get
put
Note: This Question is unanswered, help us to find answer for this one
Check Answer
269. What is the ActionView form helper tag for
<%= text_input
<%= input_tag :type=>
<%= text_field_tag
<%= text_tag
Answer
Correct Answer:
<%= text_field_tag
Note: This Question is unanswered, help us to find answer for this one
Check Answer
270. Procs are objects, Blocks are not.
true
false
Note: This Question is unanswered, help us to find answer for this one
Check Answer
271. Which of the following associations does NOT declare a many-to-many relationship?
has_and_belongs_to_many
has_many :through
has_many
Note: This Question is unanswered, help us to find answer for this one
Check Answer
272. If the class User has a belongs_to :role, which table has the foreign key?
User
Neither
Role
Both
Note: This Question is unanswered, help us to find answer for this one
Check Answer
273. For your app to route the "http://myapp.com/" to the home controller, index action; what could you add to your routes.rb file?
root_to
root =>
root :to =>
root =>
Answer
Correct Answer:
root :to =>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
274. What is the best practice to implement translations of the title of a component in the view using i18n API?
I18n.t('title.component')
I18n.t('component.title')
I18n.l('component.title')
I18n.t('title')
Answer
Correct Answer:
I18n.t('component.title')
Note: This Question is unanswered, help us to find answer for this one
Check Answer
275. What does Model.reset_column_information do?
Resets all the cached information about columns.
Resets the existing records with the provided value.
Resets the data type of the column.
Resets the column names of the table.
Resets the index of the corresponding table.
Answer
Correct Answer:
Resets all the cached information about columns.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
276. What kind of variables are Author and AUTHOR?
constant
local
class
global
Note: This Question is unanswered, help us to find answer for this one
Check Answer
277. How do you render a variable in ERB template?
<%= variable_name =>
<% variable_name %>
<%= '#{variable_name}' =%>
<%= "variable_name" =%>
Answer
Correct Answer:
<%= variable_name =>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
278. How does the Asset Pipeline (Rails 3.1 +) deal with different precompiled versions of an asset?
Append random 32 character string at precompile
Append version number to filename at precompile
Append datetime to filename at precompile
Append MD5 digest to filename at precompile
Answer
Correct Answer:
Append MD5 digest to filename at precompile
Note: This Question is unanswered, help us to find answer for this one
Check Answer
279. What is not a proper REST verb?
post
put
delete
get
update
Note: This Question is unanswered, help us to find answer for this one
Check Answer
280. What is the proper way to subclass a Module?
module SuperModule << SubModule;
module SuperModule < SubModule; end
You cannot subclass a Module.
module SuperModule << SubModule; end
module SuperModule < SubModule;
Answer
Correct Answer:
You cannot subclass a Module.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
281. Which expression will not return a sum of array elements in Ruby on Rails?
None of them. All will return the sum.
sum = 0; array.each { |e| sum += e }; sum
array.inject { |sum, e| sum + e }
array.inject(:+)
array.sum
Answer
Correct Answer:
None of them. All will return the sum.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
282. Which column type is NOT supported by Active Record?
datetime
blob
float
decimal
binary
Note: This Question is unanswered, help us to find answer for this one
Check Answer
283. Which of these code blocks cannot be right?
= form_for User do |f|
= form_for :user do |f|
= form_for @user do |f|
= form_for current_user do |f|
= simple_form_for @user do |f|
Answer
Correct Answer:
= form_for User do |f|
Note: This Question is unanswered, help us to find answer for this one
Check Answer
284. What is the output of the following? $x = 10 puts defined? $X
instance-variable
local-variable
class variable
nil
Note: This Question is unanswered, help us to find answer for this one
Check Answer
285. When you've got a form, and when the user submits invalid data, you redirect back to the edit form. If you want to show a general error message (not tied to validation errors) to the user, you'd do which of the following?
In controller: flash.now.error = message
In controller: flash[:error] = message
In controller: flash.error = message
At the top of page: <%= message %>
In controller: flash.now[:error] = message
Answer
Correct Answer:
In controller: flash[:error] = message
Note: This Question is unanswered, help us to find answer for this one
Check Answer
286. Which of these is NOT a valid way of associating models?
has_and_belongs_to_many
has_many
has_one
has_and_belongs_to
belongs_to
Answer
Correct Answer:
has_and_belongs_to
Note: This Question is unanswered, help us to find answer for this one
Check Answer
287. To randomize the order of entries in an Array, use the _______ method.
shuffle
random
sort
sample
scramble
Note: This Question is unanswered, help us to find answer for this one
Check Answer
288. What is the output of the following? puts 'a\nb'
a\nb
a/b
a b
anb
Note: This Question is unanswered, help us to find answer for this one
Check Answer
289. Which of the following controller methods is NOT properly paired with its HTTP counterpart?
CREATE for POST
SHOW for PUT
INDEX for GET
None of these
DESTROY for DELETE
Answer
Correct Answer:
SHOW for PUT
Note: This Question is unanswered, help us to find answer for this one
Check Answer
290. What is the main function of helpers used in Ruby on Rails?
Helpers are the functionality provided by the View for the modules to provide the help classes in MVC architecture.
Helpers are the functionality provided by the Controller for the modules to provide the help classes in MVC architecture.
Answer
Correct Answer:
Helpers are the functionality provided by the View for the modules to provide the help classes in MVC architecture.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
291. Functional tests are used to test what part of a Rails application?
Controllers
Models
Javascript
Views
Answer
Correct Answer:
Controllers
Note: This Question is unanswered, help us to find answer for this one
Check Answer
292. Which of the following is a correctly formatted multi-line comment?
=begin COMMENT =end
/ COMMENT
### COMMENT ###
""" COMMENT """"
/# COMMENT #/
Answer
Correct Answer:
=begin COMMENT =end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
293. The session is, by default, accessible to:
models only
controllers and models
controllers and views
models and views
controllers only
Answer
Correct Answer:
controllers and views
Note: This Question is unanswered, help us to find answer for this one
Check Answer
294. Does RoR supports multiple inheritance?
false
true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
295. String objects are _______.
Immutable
Mutable
Neither of these
Note: This Question is unanswered, help us to find answer for this one
Check Answer
296. A class variable (not class level instance variable) has a name beginning with ___________.
$
@@
@
%
Note: This Question is unanswered, help us to find answer for this one
Check Answer
297. Ruby supports single inheritance, multiple inheritance, or both?
It does not support inheritance
Single Inheritance
Multiple Inheritance
Both
Answer
Correct Answer:
Single Inheritance
Note: This Question is unanswered, help us to find answer for this one
Check Answer
298. Which is NOT an ActiveRecord migration method?
change_table
add_key
add_index
drop_table
add_column
Note: This Question is unanswered, help us to find answer for this one
Check Answer
299. A correct example of class inheritance from "Exception" into "Bomber"
class Bomber(Exception) def initialize # Instance end end
class Bomber << Exception def initialize # Instance end end
class Bomber < Exception def initialize # Instance end end
Answer
Correct Answer:
class Bomber < Exception def initialize # Instance end end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
300. When rendering a partial on a collection, what is the recommended method?
<% @collection.each do |item| %> <%= render :partial => 'partial_to_render', item %> <% end %>
<%= render :partial => 'partial_to_render', :collection => @collection %>
<%= render :partial => 'partial_to_render', :source => @collection.each %>
Answer
Correct Answer:
<%= render :partial => 'partial_to_render', :collection => @collection %>
Note: This Question is unanswered, help us to find answer for this one
Check Answer
301. In a Rails migration, what's the syntax for creating a table?
create_table => :table_name
sudo gem install make_table
rake db:create TableName
create_table :table_name
Answer
Correct Answer:
create_table :table_name
Note: This Question is unanswered, help us to find answer for this one
Check Answer
302. Ruby 1.9, what new method of building key-value pairs is supported?
:
=>
:=
Note: This Question is unanswered, help us to find answer for this one
Check Answer
303. Which of these is not a valid form helper?
radio_button
password_field
text_field
hidden_field
text_box
Note: This Question is unanswered, help us to find answer for this one
Check Answer
304. What is the output of the following? @@x = 10 puts defined? @@x
local-variable
global-variable
instance-variable
class variable
Answer
Correct Answer:
class variable
Note: This Question is unanswered, help us to find answer for this one
Check Answer
305. In the context of unit testing Rails applications, "fixture" refers to which of the following?
Predefined data for populating the testing database
The result expected from a passing unit test
Fields which remain fixed across all records in the testing database
The required action to get a unit test to pass
Answer
Correct Answer:
Predefined data for populating the testing database
Note: This Question is unanswered, help us to find answer for this one
Check Answer
306. Which does NOT append "nine" to the array: "big_data"?
big_data << "nine"
big_data.append("nine")
big_data.push("nine")
Answer
Correct Answer:
big_data.append("nine")
Note: This Question is unanswered, help us to find answer for this one
Check Answer
307. If you want to display the price of an item, with a :time_span tag, where would you place this code?
view or model
model or migration
helper_function or view
migration or helper_function
Answer
Correct Answer:
helper_function or view
Note: This Question is unanswered, help us to find answer for this one
Check Answer
308. What is the main step to add ajax call in Ruby on Rails?
:remote :true
remote => true
remote: true
:remote = true
Answer
Correct Answer:
remote: true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
309. Which command would generate a DogController with a 'bark' action?
rails g controller Dog bark
rails g c Dog bark
rails create controller Dog bark:action
rails g controller Dog
rails generate Dog:controller bark:action
Answer
Correct Answer:
rails g controller Dog bark
Note: This Question is unanswered, help us to find answer for this one
Check Answer
310. Which is an incorrectly defined method?
def method_name() # method operations
def method_name() # method operations end
def method_name # method operations end
Answer
Correct Answer:
def method_name() # method operations
Note: This Question is unanswered, help us to find answer for this one
Check Answer
311. Unit tests are used to test what part of a Rails application?
Helpers
Controllers
Models
Views
Note: This Question is unanswered, help us to find answer for this one
Check Answer
312. Where do you add named scopes?
Views
ApplicationController
Models
Migrations
Note: This Question is unanswered, help us to find answer for this one
Check Answer
313. What is not a RESTful controller action?
update
insert
edit
index
Note: This Question is unanswered, help us to find answer for this one
Check Answer
314. What is the output for the following? x = 1==1 ? "a" : "b"; puts x
a
NameError
false
true
b
Note: This Question is unanswered, help us to find answer for this one
Check Answer
315. Which is NOT a reserved Ruby logic flow word?
if
break
elsif
else
elseif
Note: This Question is unanswered, help us to find answer for this one
Check Answer
316. Of the following, which would create a new project without unit test?
$ rails new example_app --skip-bundle
$ rails new example_app -O
$ rails new example_app --database=postgresql
$ rails new example_app -T
Answer
Correct Answer:
$ rails new example_app -T
Note: This Question is unanswered, help us to find answer for this one
Check Answer
317. How would you check to see if an array named COLORS contains the the value 'red'?
COLORS.contains?('red')
COLORS.has?('red')
COLORS.include?('red')
'red'.includedIn?(COLORS)
Answer
Correct Answer:
COLORS.include?('red')
Note: This Question is unanswered, help us to find answer for this one
Check Answer
318. Which of these is NOT a default subdirectory of the app/ directory?
All of these are subdirectories of the app/ directory
models
controllers
environments
helpers
Answer
Correct Answer:
environments
Note: This Question is unanswered, help us to find answer for this one
Check Answer
319. If you have posts and each post has_many comments, how do you structure your routes?
resources :posts, :comments
resources :posts do resources :comments end
resources :comments do resources :posts end
Answer
Correct Answer:
resources :posts do resources :comments end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
320. Which is NOT an ActiveRecord query method?
where
group
has
order
select
Note: This Question is unanswered, help us to find answer for this one
Check Answer
321. Which of the following will check the array named "big_data" for the presence of a key "icecream"?
big_data.has_key["icecream"]
big_data.has_key?["icecream"]
big_data.has_key?("icecream")
Answer
Correct Answer:
big_data.has_key?("icecream")
Note: This Question is unanswered, help us to find answer for this one
Check Answer
322. If you create PostsController, where will Rails look for its templates by default?
app/views/posts
app/views/templates
app/templates
app/views
app/templates/posts
Answer
Correct Answer:
app/views/posts
Note: This Question is unanswered, help us to find answer for this one
Check Answer
323. How do you remove a column during a migration?
drop_column :column_name
remove_column :column_name
remove_column :table_name, :column_name
remove_column => :column_name
Answer
Correct Answer:
remove_column :table_name, :column_name
Note: This Question is unanswered, help us to find answer for this one
Check Answer
324. Which command, when run, will compile all assets in the 'app/assets' directory and copy compiled versions to a configured target directory ('public/assets' by default)?
rake assets:precompile
rake assets:compileanddeploy
rake assets:compile
rake assets:deploy
Answer
Correct Answer:
rake assets:precompile
Note: This Question is unanswered, help us to find answer for this one
Check Answer
325. Which is NOT a Ruby operator?
||
<=
&&
=!
!=
Note: This Question is unanswered, help us to find answer for this one
Check Answer
326. What is the most elegant way to include a javascript file needed for only one page?
Application.layout.Javascripts <<
<%= javascript_include_tag
:render => {:javascript => 'FILE NEEDED'}
Answer
Correct Answer:
<%= javascript_include_tag
Note: This Question is unanswered, help us to find answer for this one
Check Answer
327. belongs_to: Represents the inverse of a has_one (or has_many) association.
true
false
Note: This Question is unanswered, help us to find answer for this one
Check Answer
328. What is the difference between Symbol and String?
symbols, belongs to the category of immutable
string, belongs to the category of immutable
Answer
Correct Answer:
symbols, belongs to the category of immutable
Note: This Question is unanswered, help us to find answer for this one
Check Answer
329. If you want the standard restful routes for your person controller, how do you add that?
resources :person do member do post :short end collection do get :long end end
response.map{|person| => :restful}
resources :people
map.person => {:get, :post, :put}
Answer
Correct Answer:
resources :people
Note: This Question is unanswered, help us to find answer for this one
Check Answer
330. Where will routes.rb file appear?
app/routes.rb
db/routes.rb
config/routes.rb
app/config/routes.rb
Answer
Correct Answer:
config/routes.rb
Note: This Question is unanswered, help us to find answer for this one
Check Answer
331. A module cannot be subclassed or instantiated.
True
False
Note: This Question is unanswered, help us to find answer for this one
Check Answer
332. Which of the following is a working ruby while-loop?
while i < 100 do # DO THINGS i += 1
while i < 100: # DO THINGS i += 1 end
while i < 100 do # DO THINGS i += 1 end
Answer
Correct Answer:
while i < 100 do # DO THINGS i += 1 end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
333. What part of a migration runs during a rollback?
nothing
The entire migration
self.down
self.up
Answer
Correct Answer:
self.down
Note: This Question is unanswered, help us to find answer for this one
Check Answer
334. Which is NOT a model validation method?
validates_numericality_of
validates_length_of
validates_form_of
validates_presence_of
validates_uniqueness_of
Answer
Correct Answer:
validates_form_of
Note: This Question is unanswered, help us to find answer for this one
Check Answer
335. which one is class method?
class A def a end end
class A def self.a end end
Answer
Correct Answer:
class A def self.a end end
Note: This Question is unanswered, help us to find answer for this one
Check Answer
336. If you want to append an item to an array, what is the standard method?
arr.length = arr.length+1 arr[length-1] = item
arr << item
arr.map(item.clone)
arr.append(item)
Answer
Correct Answer:
arr << item
Note: This Question is unanswered, help us to find answer for this one
Check Answer
337. Determine the value of the variable x after the execution of the following code. x = [1,2,3] x.pop until x.empty? x.push(4) while x.empty?
[1,2,3]
[4]
[1]
[1,2,3,4]
Note: This Question is unanswered, help us to find answer for this one
Check Answer
338. What file will rails look for given the following erb: <%= render 'some_partial' %>?
+some_partial.html.erb
some_partial.html.erb
@some_partial.html.erb
partial_some_partial.html.erb
_some_partial.html.erb
Answer
Correct Answer:
_some_partial.html.erb
Note: This Question is unanswered, help us to find answer for this one
Check Answer
339. Imagine that you have two models: "User" and "Book", and a user can have only one book. How should the association look like in the "User" model?
belongs_to :book
has_many: books
has_one :books
has_one :book
Answer
Correct Answer:
has_one :book
Note: This Question is unanswered, help us to find answer for this one
Check Answer
340. What is the use of @ in Ruby?
instance variable
class variable
Answer
Correct Answer:
instance variable
Note: This Question is unanswered, help us to find answer for this one
Check Answer
341. Which of these javascript frameworks became the default with the release of Rails 3.1?
rails.js
jQuery
rails-script
Prototype
Note: This Question is unanswered, help us to find answer for this one
Check Answer
342. What is the use of the 'defined?' method?
To find the value of a variable
To find the memory allocated to that variable
To determine if the variable is defined at the current scope
To find whether it is a constant or variable
Answer
Correct Answer:
To determine if the variable is defined at the current scope
Note: This Question is unanswered, help us to find answer for this one
Check Answer
343. If you want the /person url to map to your dog controller and show method, what do you add to your routes?
match '/person', :to => 'dog#show'
map.resources :person
map.resources :dog
map.resources :person => :dog
Answer
Correct Answer:
match '/person', :to => 'dog#show'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
344. Which of these does NOT correctly return the version of Ruby?
-VERSION
--version
-v
Note: This Question is unanswered, help us to find answer for this one
Check Answer
345. How do you create a new user object with the name david and save it to the database?
User.build(:name => 'david')
User.create(:name => 'david')
User.new(:name => 'david')
User.make(:name => 'david')
Answer
Correct Answer:
User.create(:name => 'david')
Note: This Question is unanswered, help us to find answer for this one
Check Answer
346. Which of the following prints the "Hello WORLD!" output with a new line?
puts "Hello WORLD!"
print "Hello WORLD!"
disp( "Hello WORLD!" )
Answer
Correct Answer:
puts "Hello WORLD!"
Note: This Question is unanswered, help us to find answer for this one
Check Answer
347. is it possible to change the default port when running a rails server ?
yes
no
Note: This Question is unanswered, help us to find answer for this one
Check Answer
348. What is the default value for a global variable (before initialization)?
null
nil
0
nul
Note: This Question is unanswered, help us to find answer for this one
Check Answer
349. Which files is used to specify any default data that should be loaded into the application's database, when it is first setup?
db/default_data.rb
db/migrate/inital_load.rb
db/migrate/default_data.rb
db/seeds.rb
Answer
Correct Answer:
db/seeds.rb
Note: This Question is unanswered, help us to find answer for this one
Check Answer
350. The recommended directory in which to place your app's javascript files is:
app/assets/javascripts
app/javascripts
assets/javascripts
public/javascripts
Answer
Correct Answer:
app/assets/javascripts
Note: This Question is unanswered, help us to find answer for this one
Check Answer
351. Which of these is not a standard directory in a Rails application?
db
lib
app
All of these are standard directories
config
Answer
Correct Answer:
All of these are standard directories
Note: This Question is unanswered, help us to find answer for this one
Check Answer
352. What is a typical file extension found in the app/controllers directory
.yml
.erb
.rb
.html.erb
Note: This Question is unanswered, help us to find answer for this one
Check Answer
353. What ORM does Ruby on Rails use by default?
ActiveRails
ActiveSupport
SQL
MySQL
ActiveRecord
Answer
Correct Answer:
ActiveRecord
Note: This Question is unanswered, help us to find answer for this one
Check Answer
354. What is the output of the following ? s="foo" * 2 puts s
foo*2
foofoo
Gives an Error
foo
Note: This Question is unanswered, help us to find answer for this one
Check Answer
355. Which of the following will interpolate within a string with the variable named 'monster'?
"/monster"
"#{monster}"
{monster}
"{monster}"
Answer
Correct Answer:
"#{monster}"
Note: This Question is unanswered, help us to find answer for this one
Check Answer
356. What is the preferred method of validating that the name has been set?
validates :name, :presence => true
save!
before_save if name != nil return true end return false end
validates :name => not_null
Answer
Correct Answer:
validates :name, :presence => true
Note: This Question is unanswered, help us to find answer for this one
Check Answer
357. Migrations...
generally affect only views and sometimes controllers.
can never be reversed.
back up a project by copying it to another location.
are considered poor programming and are not used significantly in Rails.
modify a database by adding or removing columns or tables.
Answer
Correct Answer:
modify a database by adding or removing columns or tables.
Note: This Question is unanswered, help us to find answer for this one
Check Answer
358. What command do you run to update your database?
database_update
rake db:migrate
rails update
rake db:rollback
Answer
Correct Answer:
rake db:migrate
Note: This Question is unanswered, help us to find answer for this one
Check Answer
359. Ruby uses:
null
nil
Note: This Question is unanswered, help us to find answer for this one
Check Answer
360. How would you declare an Instance Variable?
@@
@
Note: This Question is unanswered, help us to find answer for this one
Check Answer
361. What command do you run to drop your database?
rails destroy
rake db:drop
rake db:migrate
database_drop
Answer
Correct Answer:
rake db:drop
Note: This Question is unanswered, help us to find answer for this one
Check Answer
362. What command do you run to create your database?
database_create
rake db:migrate
rake db:create
rails create
Answer
Correct Answer:
rake db:create
Note: This Question is unanswered, help us to find answer for this one
Check Answer
363. What is the command to install Rails?
gem install ruby_on_rails
gem install ror
gem install rails
Answer
Correct Answer:
gem install rails
Note: This Question is unanswered, help us to find answer for this one
Check Answer
364. In the MVC pattern:
MVC are the initials of the creator, Michael Vincent Clantor.
mySQL is the database, vi is the text editor, and C++ is the language.
models represent the data, views display the data, and controllers respond to user interactions
manipulators handle data, validators ensure data integrity, and communicators transfer information between them.
Answer
Correct Answer:
models represent the data, views display the data, and controllers respond to user interactions
Note: This Question is unanswered, help us to find answer for this one
Check Answer
365. Which extension is default for views html templates?
.erb
.slim
.rabl
.haml
Note: This Question is unanswered, help us to find answer for this one
Check Answer
366. What is a Gem?
A configuration item
Functionality in a package
Answer
Correct Answer:
Functionality in a package
Note: This Question is unanswered, help us to find answer for this one
Check Answer
367. Which is NOT a default Rails environment?
sandbox
test
development
production
Note: This Question is unanswered, help us to find answer for this one
Check Answer
368. What is the use of @@ in Ruby?
class variable
instance variable
Answer
Correct Answer:
class variable
Note: This Question is unanswered, help us to find answer for this one
Check Answer
369. What is the use of $ in Ruby?
$ in Ruby is treated as a class variable
$ in Ruby is treated as a global variable
Answer
Correct Answer:
$ in Ruby is treated as a global variable
Note: This Question is unanswered, help us to find answer for this one
Check Answer
370. Which of the following will delete the key-value 1 from array: "big_data"?
big_data.del(1)
big_data.del[1]
big_data.delete(1)
Answer
Correct Answer:
big_data.delete(1)
Note: This Question is unanswered, help us to find answer for this one
Check Answer
371. How can you create a new Rails project?
'rails new /path/to/new/app'
'rails /path/to/new/app'
'rails create /path/to/new/app'
Answer
Correct Answer:
'rails new /path/to/new/app'
Note: This Question is unanswered, help us to find answer for this one
Check Answer
372. What gets returned by: [1, [2, 3,[4, 5]]].flatten
[1, 2, 3, 4, 5]
[1, [2, 3, 4, 5]]
[2, 3, [4, 5]]
[1, 2, 3, [4, 5]]
{1: [2, 3, [4, 5]]}
Answer
Correct Answer:
[1, 2, 3, 4, 5]
Note: This Question is unanswered, help us to find answer for this one
Check Answer
373. A global variable has a name beginning with:
$
%
@
@@
Note: This Question is unanswered, help us to find answer for this one
Check Answer
374. What command do you run to undo the last 5 migrations
rake db:rollback STEP=5
database_undo
rake db:drop
rake db:rollback
Answer
Correct Answer:
rake db:rollback STEP=5
Note: This Question is unanswered, help us to find answer for this one
Check Answer
Ruby On Rails MCQs | Topic-wise