我继承了这段代码,但无法理解这部分:
我有以下控制器:
class MenuCategoriesController < ApplicationController
load_and_authorize_resource
after_filter lambda { |controller| controller.update_other_locals_for(@menu_category) }, :only => [:create, :update]
# GET /menu_categories
# GET /menu_categories.json
def index
...
在 application_controller 中是这样的:
def update_other_locals_for(item)
available_locals = item.menu.shop.chosen_locals
...
通常更新或创建项目时应该点击 update_other_locals_for。我设置了一个断点,这似乎永远不会发生。这需要一个 lambda 表达式吗?创建或更新后未命中的原因可能是什么?