3 가장자리,이 같은 두 개의 중첩 자원을 설정 한 :레일 3 개 중첩 자원 정의되지 않은 메서드 오류 레일에서
config/routes.rb
resources :agencies do
resources :properties
end
내가 아래에 새 속성을 만들려고 할 때 내 ORM으로 Mongomapper을 사용하고,
---> http://localhost:3000/agencies/4c3ff0f455899f0fb5000001/properties/new
NoMethodError in Properties#new
Showing /Users/peter/programming-MacBookPro/iPhone/inspector-on-rails/app/views/properties/_form.html.erb where line #1 raised:
undefined method `properties_path' for #<#<Class:0x00000100dae020>:0x00000100d97f00>
Extracted source (around line #1):
1: <%= form_for @property do |f| %>
2: <% if @property.errors.any? %>
3: <div id="error_explanation">
4: <h2><%= pluralize(@property.errors.count, "error") %> prohibited this property from being saved:</h2>
Trace of template inclusion: app/views/properties/new.html.erb
Rails.root: /Users/peter/programming-MacBookPro/p-on-rails
Application Trace | Framework Trace | Full Trace
app/views/properties/_form.html.erb:1
app/views/properties/new.html.erb:3
app/controllers/properties_controller.rb:29:in `new'
Request
Parameters:
{"agency_id"=>"4c3ff0f455899f0fb5000001"}
properties_controller.rb에서 :
응용 프로그램에서def new
@property = Property.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @property }
end
end
/뷰 기관의 기존,이 오류가 발생합니다 S/특성/_form.html.erb : 응용 프로그램/조회/등록/new.html.erb에서
<%= form_for @property do |f| %>
<% if @property.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@property.errors.count, "error") %> prohibited this property from being saved:</h2>
<ul>
<% @property.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :address_postcode %><br />
<%= f.text_field :address_postcode %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
:
<h1>New property</h1>
<%= render 'form' %>
<%= link_to 'Back', @property %>
내가 정의되지 properties_path에 대한 오류가 뭔가를 가지고 있다고 의심 대행사의 자산 정보를 중첩하여 처리합니다. 그러나 나는 form_for (@agency, @property)
같은 것이 작동하지 않기 때문에 _form.html.erb의 1 번 줄에 불만을 처리하는 방법을 알아낼 수 없습니다.
아이디어가 있으십니까?
감사합니다. edit_agency_property_path (@agency, @property) 등 다양한 URL 도우미도 생성된다는 사실을 발견했습니다. 도움을 주셔서 감사합니다. – futureshocked