我有一个经过身份验证的登录和一个联系人模块......这个想法是,用户有多个联系人......联系人类有名称和号码作为它的属性......但是当我尝试创建一个联系人时,它会抛出一个错误说明"unknown attribute: user_id"
......我哪里出错了?我尝试添加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