我有一个嵌套模型
resources: customers do
resources: readings
end
我正在尝试创建一个新的客户阅读。我在读数控制器中的新动作是
#GET /customers/:customer_id/readings/new
def new
#1st you retrieve the customer
customer = Customer.find(params[:customer_id])
#2nd you build a new one
@reading = customer.readings.build
respond_to do |format|
format.html #new.html.erb
end
end
我在读数文件夹中创建新读数的视图是
<div class = "page-header">
<h1> New Readings </h1>
</div>
<%= render 'form_reading' %>
我的 _form_reading 是
<%= simple_form_for [@reading.customer, @reading], :html => { :class => 'form-horizontal' } do |f| %>
<%= render "shared/error_messages", :target => @reading %>
<%= f.input :customer_id %>
<%= f.input :date_of_reading, :as => :date %>
<%= render_readings_conditionally(f) %>
<div class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
customer_reading_path, :class => 'btn' %>
</div>
<% end %>
但是,我很困扰,对 /customers/1/readings/new 的调用返回
没有路线匹配 {:action=>"show", :controller=>"readings"}
我错过了什么?