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的參數是不兩個控制器都一樣。
我該如何使這項工作無需重複自己?