Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Ruby On Rails Interview Questions and Answers

Ques 41. WHERE SHOULD YOU PUT CODE THAT IS SUPPOSED TO RUN WHEN YOUR APPLICATION LAUNCHES in Ruby on Rails?

Ans. In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to require ‘rails/all’ in config/application.rb.

Is it helpful? Add Comment View Comments
Ques 42. What deployment tools do you use for Ruby on Rails?
Ans. Capistrano is a popular deployment tool.
Is it helpful? Add Comment View Comments
Ques 43. What deployment tools do you use for Ruby on Rails?
Ans. Capistrano is a popular deployment tool.
Is it helpful? Add Comment View Comments
Ques 44. How can you migrate your database schema one level down?
Ans.

The rake tool does most of the migrations. 

It has this nifty syntax to go back one step:

rake db:rollback

If you want to rollback all the way to the beginning you would use:

rake db:reset

This would drop the database, recreate the Database and load the current schema into it

If you want to rollback multiple steps at the same time you would use:

rake db:rollback STEP=3

To rollback all the way and if you are not worried about losing the data then you can drop the database completely with purge like this:

rake db:purge
Is it helpful? Add Comment View Comments
Ques 45. What is Sweeper in Ruby on Rails?
Ans.

Sometimes you want to have control over how often and when the cache expires. 

Sometimes it is a good idea to have the system determine that on a logical basis. Say you have a list of product on your site and you want to reload the cache each time a new product is added/updated/deleted, then you can achieve this by using the sweeper. 

class ProductSweeper < ActionController::Caching::Sweeper
  OBSERVE PRODUCT# This sweeper is going to keep an eye on the Product model 
  # If our sweeper detects that a Product was created call this
  def after_create(product)
    expire_cache_for(product)
  end
  # If our sweeper detects that a Product was updated call this
  def after_update(product)
    expire_cache_for(product)
  end
  # If our sweeper detects that a Product was deleted call this
  def after_destroy(product)
    expire_cache_for(product)
  end
  private
  def expire_cache_for(product)
    # Expire the index page now that we added a new product
    expire_page(:controller => 'products', :action => 'index')
    # Expire a fragment
    expire_fragment('all_available_products')
  end
end
Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2016 WithoutBook