Ruby on rails 调用嵌套模型视图
我有一个嵌套模型Ruby on rails 调用嵌套模型视图,ruby-on-rails,nested-forms,Ruby On Rails,Nested Forms,我有一个嵌套模型 resources :customers do resources :readings end 我现在想从客户的show视图访问我的../customerid/Readers/new视图 在客户显示视图中,如何使用按钮调用新的读数视图 客户的show.html <%- model_class = Customer -%> <div class="page-header"> <h1><%=t '.title', :default =
resources :customers do
resources :readings
end
我现在想从客户的show视图访问我的../customerid/Readers/new视图
在客户显示视图中,如何使用按钮调用新的读数视图
客户的show.html
<%- model_class = Customer -%>
<div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human %></h1>
</div>
<dl class="dl-horizontal">
<dt><strong><%= model_class.human_attribute_name(:name) %>:</strong></dt>
<dd><%= @customer.name %></dd>
<dt><strong><%= model_class.human_attribute_name(:customer_currency) %>:</strong></dt>
<dd><%= @customer.customer_currency %></dd>
<dt><strong><%= model_class.human_attribute_name(:payment_terms) %>:</strong></dt>
<dd><%= @customer.payment_terms %></dd>
<dt><strong><%= model_class.human_attribute_name(:phase_type) %>:</strong></dt>
<dd><%= @customer.phase_type %></dd>
<dt><strong><%= model_class.human_attribute_name(:billing_address) %>:</strong></dt>
<dd><%= @customer.billing_address %></dd>
<dt><strong><%= model_class.human_attribute_name(:first_name) %>:</strong></dt>
<dd><%= @customer.first_name %></dd>
<dt><strong><%= model_class.human_attribute_name(:last_name) %>:</strong></dt>
<dd><%= @customer.last_name %></dd>
<dt><strong><%= model_class.human_attribute_name(:mobile) %>:</strong></dt>
<dd><%= @customer.mobile %></dd>
<dt><strong><%= model_class.human_attribute_name(:email) %>:</strong></dt>
<dd><%= @customer.email %></dd>
</dl>
<div class="form-actions">
<%= link_to t('.back', :default => t("helpers.links.back")),
customers_path, :class => 'btn' %>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_customer_path(@customer), :class => 'btn' %>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
customer_path(@customer),
:method => 'delete',
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
:class => 'btn btn-danger' %>
</div>
model\u class.model\u name.human%>
:
:
:
:
:
:
:
:
:
t(“helpers.links.back”),
客户路径:class=>btn'>
t(“helpers.links.edit”),
编辑客户路径(@customer),:class=>btn'>
t(“helpers.links.destroy”),
客户路径(@customer),
:method=>“delete”,
:data=>{:confirm=>t('.confirm',:default=>t(“helpers.links.confirm”,:default=>'确定吗?)},
:class=>“btn btn危险”%>
我及时解决了它
<%= link_to 'Readings', customer_readings_path(@customer) %> |
|
我及时解决了它
<%= link_to 'Readings', customer_readings_path(@customer) %> |
|
根据Ruby on Rails路由指南,要获取以下URL/customers/:customer\u id/readings/new
,请使用以下URL:
customer_readings_path(@customer) # Generate the path for new Reading which belongs to @customer
根据Ruby on Rails路由指南,要获取以下URL/customers/:customer\u id/readings/new
,请使用以下URL:
customer_readings_path(@customer) # Generate the path for new Reading which belongs to @customer