Rails 4 before_action,将参数传递给调用的方法 [英] Rails 4 before_action, pass parameters to invoked method
本文介绍了Rails 4 before_action,将参数传递给调用的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
class SupportsController < ApplicationController
before_action :set_support, only: [:show, :edit, :update, :destroy]
....
是否可以将字符串传递给方法 set_support
以应用于所有 4 种视图方法?是否可以为视图中的每个方法将不同的字符串传递给方法 set_support
?
Is it possible to pass a string to the method set_support
to be applied for all 4 view methods?
Is it possible to pass a different string to the method set_support
for each method in the view?
推荐答案
before_action only: [:show, :edit, :update, :destroy] do
set_support("value")
end
这篇关于Rails 4 before_action,将参数传递给调用的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文