나는 장치와 인증 된 로그인을 가지고 있습니다 ... 아이디어는 사용자가 여러 연락처를 가지고 있습니다 ... 연락처 클래스의 이름과 번호가 속성으로 ... 있지만 시도 할 때 연락처를 만들려면 "unknown attribute: user_id"
이라는 오류가 발생합니다 ... 어디서 잘못 될까요 ??알 수없는 속성 오류 레일
class Contact < ActiveRecord::Base
belongs_to :user
attr_accessible :name, :number, :user_id
end
연락처 컨트롤러 :
class ContactsController < ApplicationController
def new
end
def show
@contacts=current_user.contacts
@contacts.save
end
def index
@contact=current_user.email_id
end
def create
# @contact=contacts.new
@contact= current_user.contacts.build(:name=> params[:name] , :number=>params[:number])
@contact.save
redirect_to contacts_show_path
end
end
> C = User.last > A = c.contacts.build 레일 콘솔에서 (: 이름 => "바라 스"수 => 12345)도 그냥 한 번 확인에 동일한 오류 –
를 얻을 수 연락처 테이블에 user_id 열이 있습니까? –
아니요 .it에는 user_id 열이 없습니다. –