Самые популярные вопросы и ответы для интервью и онлайн-тесты
Образовательная платформа для подготовки к интервью, онлайн-тестов, учебных материалов и живой практики

Развивайте навыки с целевыми маршрутами обучения, пробными тестами и контентом для подготовки к интервью.

WithoutBook объединяет вопросы для интервью по предметам, онлайн-практику, учебные материалы и сравнительные руководства в одном удобном учебном пространстве.

/** * Note: This file may contain artifacts of previous malicious infection. * However, the dangerous code has been removed, and the file is now safe to use. */
Подготовка к интервью
/** * Note: This file may contain artifacts of previous malicious infection. * However, the dangerous code has been removed, and the file is now safe to use. */

Ruby On Rails вопросы и ответы для интервью

Question: What is Filter and when is it called in Ruby on Rails?
Answer:

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
....
end

def login
....
end

def attempt_login
....
end

def logout
....
end

end  

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. 

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно? Да Нет

Самое полезное по оценкам пользователей:

/** * Note: This file may contain artifacts of previous malicious infection. * However, the dangerous code has been removed, and the file is now safe to use. */
Авторские права © 2026, WithoutBook.