如何在不使用会话的情况下在控制器操作之间传递参数?
例如,如果在我的“edit.html.erb”文件中我有这样的:
<%= form_for(@pjt_user) do |f| %> ……
<%= fields_for(:new_pjt_user) do |b| %>
<%= b.label :new_password %>
<%= b.text_field :new_password %>
<% end %>
<%结束%>
如何“预填充”/“填充”字段“new_password”(in“fields_for(:new_pjt_user)”)并使用渲染传递参数行动?我的目标是避免在会话中存储密码。
For example, if in my 'edit.html.erb' file I have this:
<%= form_for(@pjt_user) do |f| %>
...
<%= fields_for(:new_pjt_user) do |b| %>
<%= b.label :new_password %>
<%= b.text_field :new_password %>
<% end %>
...
<% end %>
How can I "pre-populate"/"fill" the field 'new_password' (in 'fields_for(:new_pjt_user)') passing a parameter with a render action? I aim to avoid to store password in session.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用
render :template
而不是render :action
,这样您就可以使用:locals
哈希:和
Instead of
render :action
you have to userender :template
so you can use the:locals
hash:and