просмотр (нужна помощь здесь) или мне нужно изменить accepts_nested_attributes.Мне нужна форма, которая создает свойство и связанный адрес, начиная с города.В этот момент я получаю следующую ошибку: unknown attribute: address
.Далее я хочу перенаправить обратно после создания;не уверен, как это сделать с использованием метода Legited_resources.Благодарю вас.
= form_for Property.new do |f|
= f.fields_for :address do |builder|
= builder.label :city
= builder.text_field :city
= f.submit
class Property < ActiveRecord::Base
include ActiveRecord::Transitions
include ActsAsAsset
include Amendable
include Searchable
acts_as_taggable_on :tags
has_many :addresses, :as => :addressable
has_many :escrows
has_many :events, :as => :entity
has_many :phone_numbers, :as => :phoneable
accepts_nested_attributes_for :addresses
.
.
.
end
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
belongs_to :address_category
has_many :notes, :as => :notable
validate :not_blank
validates :addressable, :presence => true
private
def not_blank
self.errors.add :base, 'cannot be blank' if
self.attributes.values.all? {|attr| attr.blank? }
end
end
class PropertiesController < ApplicationController
inherit_resources
before_filter :authenticate_user!
def index
end
def show
end
end