ネストされたモデルがあります
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/newreturnsへの電話
{:action => "show"、:controller=>"readings"}に一致するルートはありません
私は何が欠けていますか?