【问题标题】:How to pass locales in simple_fields_for partials?如何在 simple_fields_for 局部传递语言环境?
【发布时间】:2015-09-24 17:25:17
【问题描述】:

我的视图中有以下代码:

<%= simple_form_for @user do |f| %>
  <%= f.input :email %>
  <%= simple_fields_for :profile do |p| %>
   <%= render 'profile_fields', f => p %>
 <% end %>
 <%= f.submit %>

所以我试图通过以下方式传递“profile_fields”部分的区域设置,并尝试部分访问该区域设置,它抛出了“未定义的方法类型”之类的错误。

<%= simple_fields_for :profile do |p| %>
 <%= render 'profile_fields', f => p, :type => "Test" %>
<% end %>

谁能帮帮我?

【问题讨论】:

    标签: ruby-on-rails-3 simple-form nested-forms nested-attributes simple-form-for


    【解决方案1】:

    替换这个,

    <%= render 'profile_fields', f => p, :type => "Test" %>
    

    <%= render 'profile_fields', :locals => {:f=> p, :test=> "Test"} %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 2017-11-01
      • 2015-12-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多