Skip to content

Instantly share code, notes, and snippets.

@petehuang
Last active December 16, 2015 17:30
Show Gist options
  • Save petehuang/5471229 to your computer and use it in GitHub Desktop.
Save petehuang/5471229 to your computer and use it in GitHub Desktop.
Errors: Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA") ActiveRecord::UnknownAttributeError: unknown attribute: user_id
0000_create_appointments.rb
class CreateAppointments < ActiveRecord::Migration
def change
create_table :appointments do |t|
t.integer :user_id
t.integer :receiver_id
t.date :prepday
t.time :preptime
t.string :preplocation
t.text :notes
t.timestamps
end
end
end
Failures:
1) Appointment
Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
ActiveRecord::UnknownAttributeError:
unknown attribute: user_id
# ./spec/models/appointment_spec.rb:7:in `new'
# ./spec/models/appointment_spec.rb:7:in `block (2 levels) in <top (required)>'
2) Appointment
Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
ActiveRecord::UnknownAttributeError:
unknown attribute: user_id
# ./spec/models/appointment_spec.rb:7:in `new'
# ./spec/models/appointment_spec.rb:7:in `block (2 levels) in <top (required)>'
3) Appointment
Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
ActiveRecord::UnknownAttributeError:
unknown attribute: user_id
# ./spec/models/appointment_spec.rb:7:in `new'
# ./spec/models/appointment_spec.rb:7:in `block (2 levels) in <top (required)>'
4) Appointment
Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
ActiveRecord::UnknownAttributeError:
unknown attribute: user_id
# ./spec/models/appointment_spec.rb:7:in `new'
# ./spec/models/appointment_spec.rb:7:in `block (2 levels) in <top (required)>'
5) Appointment
Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
ActiveRecord::UnknownAttributeError:
unknown attribute: user_id
# ./spec/models/appointment_spec.rb:7:in `new'
# ./spec/models/appointment_spec.rb:7:in `block (2 levels) in <top (required)>'
6) Appointment
Failure/Error: @appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
ActiveRecord::UnknownAttributeError:
unknown attribute: user_id
# ./spec/models/appointment_spec.rb:7:in `new'
# ./spec/models/appointment_spec.rb:7:in `block (2 levels) in <top (required)>'
class Appointment < ActiveRecord::Base
attr_accessible :notes, :prepday, :preplocation, :preptime, :receiver_id, :user_id
end
appointment_spec.rb
require 'spec_helper'
describe Appointment do
let(:user) { FactoryGirl.create(:user)}
let(:other_user) { FactoryGirl.create(:user)}
before do
@appointment = Appointment.new(user_id: user.id, receiver_id: other_user.id, prepday:Date.today, preptime:Time.now, preplocation: "Norris", notes: "NA")
end
subject { @appointment }
it { should respond_to(:user_id)}
it { should respond_to(:receiver_id)}
it { should respond_to(:prepday)}
it { should respond_to(:preptime)}
it { should respond_to(:preplocation)}
it { should respond_to(:notes)}
end
wireless-165-124-217-23:prepfind Pete$ rake db:test:prepare
You have 1 pending migrations:
20130426215406 CreateAppointments
Run `rake db:migrate` to update your database then try again.
wireless-165-124-217-23:prepfind Pete$ rake db:migrate
== CreateAppointments: migrating =============================================
-- create_table(:appointments)
rake aborted!
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "appointments" already exists: CREATE TABLE "appointments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "receiver_id" integer, "prepday" date, "preptime" time, "preplocation" varchar(255), "notes" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment