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. What is Filter and when is it called in Ruby on Rails?

Filters are methods that are called either before/after a controller action is called. 

Say a user requests a controller action such as userdashboard/index

In such a case a filter can be setup so that the UserDashboard/index page is only accessible to loggedin users by adding the following lines towards the beginning of the page:

class UserDashboardController < ApplicationController

  before_filter :confirm_logged_in,  :except => [:login, :attempt_login, :logout]  
def index

def login

def attempt_login

def logout


In the code above the condition “confirm_logged_in” is checked before all actions, except login, logout & attempt_login. 

After filters (after_filter) are not used too much but they have the effect of executing some code after a particular action has completed. 

Think of them like triggers that get executed automatically — just like a database trigger. 

Is it helpful? Yes No

Most helpful rated by users:

©2016 WithoutBook