要调用此部分视图:
<% form_for(:subscription, :url => city_subscriptions_path(@city)) do |form| %>
<%= form.hidden_field :city_id, :value => @city.id %>
<%= form.text_field :email, :size => 30 %>
<%= form.submit "Email Me" %>
<% end %>
由于我在不同的地方使用这个局部视图,我如何更改调用者以便它将传递form_for
助手的哈希值?所以当调用帮助程序时会是这样的:
<% form_for(:subscription, :url => city_subscriptions_path(@city), :html => {:id => 'main_input' }) do |form| %>
<%= form.hidden_field :city_id, :value => @city.id %>
<%= form.text_field :email, :size => 30 %>
<%= form.submit "Email Me" %>
<% end %>
答案 0 :(得分:6)
<%= render :partial => "shared/subscription", :locals => {:foo => "bar", :foofoo => ["bar", "bar"]}
在局部视图中,使用它们:
<%= foo #this outputs "bar" %>
<%= foofoo.to_s %>