Ich habe einen Controller für Property und andere für Land ein Objekt verfügt über ein Landsimple_forms mit zwei Klassen
My Property Modell
class Property < ApplicationRecord
acts_as_paranoid
has_one :country, class_name: Country
belongs_to :company
accepts_nested_attributes_for :country
validates :name, presence: true
validates :address, presence: true
Mein Land Modell
class Country < ApplicationRecord
acts_as_paranoid
belongs_to :property
validates :name, presence: true
validates :isoalpha2, presence: true
validates :isolapha3, presence: true
Und
, wenn ich will eine Eigenschaft mit meiner Sicht (new.html.erb)
<%= simple_form_for [@property, @country], url: property_new_path do |f| %>
<% if @property.errors.any? %>
<%= pluralize(@property.errors.count, "error") %> prohibited
this property from being saved:
<% @property.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<% end %>
<%= f.input :name %>
<%= f.input :description %>
<%= f.input :address %>
<%= f.submit %>
ich die folgende Fehlermeldung hinzuzufügen:
nicht definierte Methode `Beschreibung‘ für # < Land: 0x8de0b20 >
ich weiß nicht, warum statt Eigentum der Land Klasse nimmt, weil Beschreibung Teil des Property-Controller
Dank ist
nicht funktioniert, warum Länder? und warum haben Sie die Reihenfolge zuerst <@> Land und später <@> Eigenschaft geändert? –
Erste Kasse http://guides.rubyonrails.org/routing.html#nested-resources –