1
我有两个控制器:如何根据控制器使用各种参数调用before_filter?
class MyController < ApplicationController
before_filter :get_model
# Actions
end
class MyOtherController < ApplicationController
before_filter :get_model
# Actions
end
在我ApplicationController
,我有我用它来得到一定的模型功能:
def get_model
@model = Model.find(params[:model_id])
end
然而,这将持有该模型ID的参数是不两个控制器都一样。
我该如何使这项工作无需重复自己?