Questions tagged «before-filter»

5
带有参数的before_filter
我有一种方法可以执行以下操作: before_filter :authenticate_rights, :only => [:show] def authenticate_rights project = Project.find(params[:id]) redirect_to signin_path unless project.hidden end 我也想在其他一些Controller中使用此方法,因此我将该方法复制到了application_controller中包含的帮助器中。 问题是,在某些控制器中,项目的ID不是:id符号,而是fe :project_id(也:id存在fe (对于另一个模型) 您将如何解决这个问题?是否有一个选项可以向before_filter操作添加参数(以传递正确的参数)?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.