Ruby on Rails Test
where we use attr_accessor and attr_accessible in rails ?
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_sto...
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> ...
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)...
For the String class, what's the difference between "#slice" and "#slice!"?
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" r...
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 PartyA...
How can a partial called "cart" be rendered from a controller called "ProductsController", assuming the partial is in a directory called "shared"?
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)?
If a controller is named "Users", what would its helpers module be called?
If a float is added to an integer, what is the class of the resulting number? i.e. 1.0 + 2
If a method #decoupage(n) is described as O(n^2), what does that mean?
If a model called BlogComment is defined, what would its DB table be called?
In a has_many association, what is the difference between build and new? // user.rb has_many :posts // post.rb belongs_to :user
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?
In a Rails application, the developmental and production configuration are stored in the:
In a Rails Migration, which of the following will make a column unique, and then have it indexed?
In order to enable locking on a table, which of the following columns is added?
In the case of Rails application performance optimization, select all valid ways to do assets compilation:
Is an AJAX call synchronous or asynchronous?
Rails automatically requires certain files in an application. Which of the following files are automatically included without an explicit 'require' being necessary?
Select all incorrect statements regarding the Ruby Version Manager (RVM):
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 mean...
The =~ operator is used to do inline Regular Expression matching, for instance: "function" =~ /fun/ "function" =~ /dinosaurs/ What are possible return values for the =~ matcher?
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?
Unit tests are used to test which of the following components of Ruby on Rails?
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?
Using ERB for views, what filename should be given to a partial called 'login'?
What component of Rails are tested with unit tests?
What declaration would you use to set the layout for a controller?
What does REST stand for?
What does the 4xx series of HTTP errors represent?
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 ...
What is best way to create primary key as a string field instead of integer in rails.
What is difference between "has_one" and "belong_to"?
What is green-threading?
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)...
What is the behavior of class variables with subclasses?
What is the best way to get the current request URL in Rails?
What is the convention for methods which end with a question mark? e.g. #all?, #kind_of?, directory?
What is the difference between _url and _path while being used in routes?
What is the difference between :dependent => :destroy and :dependent => :delete_all in Rails?
What is the output of the following code in Ruby? x= "A" + "B" puts x y= "C" << "D" puts y
What is the output of the following code? &quot;test&quot;*5
What is the output of the following code? puts "aeiou".sub(/[aeiou]/, '*')
What is the output of the following code? $val = 20 print "Sample Text " if $val
What is the output of the following Ruby code? puts "The multiplication output of 10,10,2 is #{10*10*2}"
What is the recommended Rails way to iterate over records for display in a view?
What is the Singleton design pattern?
When a new controller named "admin2" is created, the JS and the CSS files are created in:
When using full-page caching, what happens when an incoming request matches a page in the cache?
Which gem is used to install a debugger in Rails 3?
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();" %>
Which of the following actions is fired by default when a new controller is created?
Which of the following assertions are used in testing views?
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 ...
Which of the following code samples will get the index of |page| inside of a loop?
Which of the following commands adds the data model info to the model file?
Which of the following commands will clear out sample users from the development database?
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?
Which of the following controller actions (by default) are best suited to handle the GET HTTP request?
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 }
Which of the following HTML template languages are supported by Ruby?
Which of the following is not a built-in Rails caching strategy used to reduce database calls?
Which of the following is not true about log levels in Ruby on Rails?
Which of the following is the correct syntax for an input field of radio buttons in form_for?
Which of the following is the correct way to know the Rails root directory path?
Which of the following is the correct way to rollback a migration?
Which of the following is the correct way to skip ActiveRecords in Rails 3?
Which of the following is the default way that Rails seeds data for tests?
Which of the following is true about writing tests for a Ruby on Rails application?
Which of the following items are stored in the models subdirectory?
Which of the following methods is used to check whether an object is valid or invalid?
Which of the following options is used to create a form HTML in the erb files?
Which of the following options will disable the rendering of the view associated with a controller action?
Which of the following options, when passed as arguments, skips a particular validation?
Which of the following replaced the Prototype JavaScript library in Ruby on Rails as the default JavaScript library?
Which of the following serves as a structural skeleton for all HTML pages created?
Which of the following statements is incorrect?
Which of the following validations in Rails checks for null fields?
Which of the following will disable browser page caching in Rails?
Which of the following will return a User object when used with a model which deals with a table named User?
Which part of the MVC stack does ERB or HAML typically participate in?
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?