I have two independent models : User
and Invitation
. I'm trying to check a condition in these 2 different table with ActiveRecord.
Schema.rb
create_table "invitations", force: :cascade do |t|
t.string "invit_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "provider"
t.string "uid"
t.string "facebook_picture_url"
t.string "first_name"
t.string "last_name"
t.boolean "admin"
t.string "invit_ref"
t.string "invit_one"
t.string "invit_two"
t.string "token"
t.datetime "token_expiry"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Problem:
User.where(:invit_one =>invit_ref)
.or(User.where(:invit_two=>invit_ref))
.or(Invitation.where(:invit_name =>invit_ref)).blank?
I can either do Invitation.where(:invit_name =>invit_ref).blank?
alone or User.where(:invit_two =>invit_ref).blank?
but not combine the two expressions
Unfortunately, I get a "PG::UndefinedTable: ERROR: missing FROM-clause entry for table "invitations"
on this simple query.
Can you help me to figure why?