Rails关系 - SQLite3 :: SQLException:没有这样的列

时间:2014-08-25 10:49:24

标签: ruby-on-rails migration database-migration attr table-relationships

我收到错误会发生什么事?

显示/Users/manu/Desktop/videocv/app/views/resumes/index.html.erb第16行:

SQLite3 :: SQLException:没有这样的列:resumes.candidate_id:SELECT"恢复"。* FROM"简历"在哪里"恢复"。" candidate_id" =?限制1 提取的来源(第16行): 13 14 15 16 17 18 19

 <tbody>
   <% @resumes.each do |resume| %>
     <tr>
       <td><%= current_candidate.resume.name %></td>
       <td><%= current_candidate.resume.lastname %></td>
       <td><%= current_candidate.resume.age %></td>
       <td><%= link_to 'Show', resume %></td>

查看

    <h1>Listing resumes</h1>

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Lastname</th>
      <th>Age</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @resumes.each do |resume| %>
      <tr>
        <td><%= current_candidate.resume.name %></td>
        <td><%= current_candidate.resume.lastname %></td>
        <td><%= current_candidate.resume.age %></td>
        <td><%= link_to 'Show', resume %></td>
        <td><%= link_to 'Edit', edit_resume_path(resume) %></td>
        <td><%= link_to 'Destroy', resume, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Resume', new_resume_path %>

candidate.rb

class Candidate < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

   has_one :resume
end

resume.rb

class Resume < ActiveRecord::Base

    belongs_to :candidate
end

数据库架构

ActiveRecord::Schema.define(version: 20140825102626) do

  create_table "candidates", force: true 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.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "resume_id"
  end

  add_index "candidates", ["email"], name: "index_candidates_on_email", unique: true
  add_index "candidates", ["reset_password_token"], name: "index_candidates_on_reset_password_token", unique: true
  add_index "candidates", ["resume_id"], name: "index_candidates_on_resume_id"

  create_table "resumes", force: true do |t|
    t.string   "name"
    t.string   "lastname"
    t.integer  "age"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

end

0 个答案:

没有答案