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”,:con troller =>“readings”}
我在想什么?
谢谢,它已经工作。其实我编辑它到customer_readings_path – zurik