1
我只想了解rails示波器。任何好的解释都会有帮助。Rails示波器不能显示正确的信息 - Rails 4
- 我想只显示谁拥有有就业
我使用的范围,试图显示此简历用户:
scope :resumes_with_employments, -> { where("id in (select resume_id from employments)") }
我有2个用户。他们都有工作简历,但只有一个用户正在展示。
车型
user.rb
has_one :resume
resume.rb
belongs_to :user
has_many :employments
employment.rb
belongs_to :resume
模式
create_table "users", force: true do |t|
t.string "email",
t.string "firstname"
t.string "lastname"
t.string "city"
end
create_table "resumes", force: true do |t|
t.string "address"
t.string "postcode"
t.text "summary"
t.integer "user_id"
end
create_table "employments", force: true do |t|
t.string "companyname"
t.date "datestart"
t.date "dateend"
t.integer "resume_id"
t.string "employer_name"
t.string "employer_tel"
t.string "employer_address"
t.string "employer_location"
t.string "employer_city"
t.string "employer_postcode"
t.string "employer_email"
end
谢谢@ spickermann我得到这个错误,我不太明白SQLite3 :: SQLException:不明确的列名称:ID:选择DISTINCT COUNT(DISTINCT“用户”。“ID”)从“用户”INNER JOIN“恢复”ON“恢复”。 “user_id”=“users”。“id”INNER JOIN“employments”ON“employments”。“resume_id”=“resumes”。“id”WHERE(id in(select user_id from resumes))'再次进入它 – ARTLoe
哦,我看到 - 我有这个方法,试图做一个计数,这是创建错误“<%= pluralize(@ users.resumes_with_employments.count,'jobseeker')%>' – ARTLoe
@ARTLoe我更新了我的解决异常的答案。 – spickermann