这是我的模型:
class User < ActiveRecord::Base
has_many :appointments
has_many :doctors, :through => :appointments
end
class Doctor < ActiveRecord::Base
has_many :appointments
has_many :users, :through => :appointments
end
class Appointment < ActiveRecord::Base
belongs_to :doctor
belongs_to :user
end
调用控制器动作的代码:
$.ajax({
type: "POST",
url: "/create",
data: {
appointment_date: date,
doctor_id: "1",
user_id: "1"
}
// ETC。 });
行动:
def create
@appointment = Appointment.new(:appointment_date, :doctor_id, :user_id)
if @appointment.save
flash[:success] = "Welcome!"
redirect_to @user
else
alert("failure!")
end
我得到了这个错误:
ArgumentError (wrong number of arguments (3 for 0..1)):
如何处理这个错误?有什么建议吗?谢谢。