过滤特定参数

时间:2017-09-28 10:39:12

标签: ruby-on-rails ruby-on-rails-4

我知道我可以用

过滤参数
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<button type="button" data-button="lab" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<button type="button" data-button="lab 123" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<div id="myModal" class="modal fade" role="dialog">
	<div class="modal-dialog">

		<!-- Modal content-->
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<h4 class="modal-title">Modal Header</h4>
			</div>
			<div class="modal-body">
				<p id="buttonText"></p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			</div>
		</div>
	</div>
</div>

但是如果我需要从特定模型中过滤特定参数,例如:

我有模型config.filter_parameters << :password Customer{name, address, phone},但我需要Supplier{name, address, phone}:address过滤

我可以这样做吗?

1 个答案:

答案 0 :(得分:2)

您可以通过将参数的字符串传递给前缀为模型名称的过滤参数来完成此操作,如下所示

config.filter_parameters << 'supplier.address'

您可以在此处查看中间件正在执行的操作Action Dispatch Filter Parameters