我在两个不同的模型中有两个字段,它们将位置值存储在一个数组中,我想要实现的是一个控制器实例变量,它可以匹配两个数组中的任何相同值,然后在索引视图中显示它。但是,当我尝试这段代码时
@submissions = Submission.select(Desired_Location: current_agent.Company_Business_Location)
它抛出此错误:
Unsupported argument type: Hash. Construct an Arel node instead
提交模式:
create_table "submissions", force: :cascade do |t|
t.string "First_Name"
t.string "Last_Name"
t.integer "Phone"
t.string "Email"
t.string "Desired_Location"
t.integer "number_of_beds"
t.integer "number_of_occupants"
t.integer "Rent_price_per_month_gbp"
t.date "Max_move_in_date"
t.string "Tenant_Occupation"
t.string "Contact_me_on"
t.boolean "Furnished"
t.string "Current_Address"
t.text "Property_Requirements"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.integer "location_id"
t.index ["location_id"], name: "index_submissions_on_location_id"
t.index ["user_id"], name: "index_submissions_on_user_id"
end
代理模式:
create_table "agents", 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.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "Company_Name"
t.string "Company_Email"
t.string "Company_Phone"
t.string "Company_Address"
t.string "Company_Business_Location"
t.string "Contact_Name"
t.string "Contact_Email"
t.string "Contact_Phone"
t.integer "location_id"
t.index ["email"], name: "index_agents_on_email", unique: true
t.index ["location_id"], name: "index_agents_on_location_id"
t.index ["reset_password_token"], name:
"index_agents_on_reset_password_token", unique: true
end
数据如何存储在 Desired_Location 和 Company_Business_Location 字段中的示例:
["", "Abbey Wood", "Acton", "Anerley", "Angel"]