0
と、ArgumentErrorが動作していないbelongs_toの関連は名前 `顧客件見つかりました。それはまだ定義されていますか?Railsの関連付けにhas_manyとProposalsControllerの#インデックス</p> <p>に
このエラーは私のアプリにはあります。解決策を見つけることができません。何か案は?ここで
はモーダルです:ここでは
class Client < ActiveRecord::Base
has_paper_trail
has_many :documents
accepts_nested_attributes_for :documents, allow_destroy: true, reject_if: :all_blank
end
と
class Document < ActiveRecord::Base
has_paper_trail
belongs_to :client
accepts_nested_attributes_for :clients, allow_destroy: true, reject_if: :all_blank
validates :name, presence: true
end
ドキュメント用のコントローラです:
def index
if current_user.admin?
@documents = Document.paginate(page: params[:page], :per_page => 20)
else
@documents = Document.where("user_id = ?", current_user).paginate(page: params[:page], :per_page => 20)
end
end
- 私はドキュメントのためのDBに "CLIENT_ID" を入れています。
- 安全なパラメータを両方のコントローラに入れました。
あるので、
:clients
がaccepts_nested_attributes_for
に単数形でなければなりませんが、あなたは 'ProposalsController#1 index'からあなたのコードが含まれてもらえますか?ここの定義から 'document.client'を呼び出すことはできますが、' document.clients'は呼び出さないことに注意してください。 – Julie@Julieが追加されました。しかし、try/documents/new errorがProposalsController#newでない場合。コントローラ内のすべてのメソッドで発生します。 – DanielsV