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