0

我正在尝试允许用户在我的网站上上传他们的简历

这是我在控制器中的内容

def resume
    if signed_in?
    @resume = current_user.resumes.build
  end
end

这是我创建的表

create_table "resumes", :force => true do |t|
    t.string   "content"
    t.integer  "user_id"
    t.boolean  "share"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

我在视图中使用它 (static_pages\resume.html.erb)

<% if signed_in? %>
<%= form_for @resume, :html => {:multipart => true} do |f| %>
  <%= render 'shared/error_messages', object: @resume %>
    <div class="ItemInput">Add your resume:<br>
  <%= f.file_field :content %>
</div>
<center><%= f.submit "Upload", class: "btn btn-large btn-primary" %>
<% end %>
<% end %>

我在正确的轨道上吗?我收到此错误:

NoMethodError in StaticPagesController#resume

undefined method `resumes' for #<User:0x5562b40>

这是resume.rb

class Resume < ActiveRecord::Base
  attr_accessible :content, :share, :user_id
  belongs_to :user
  validates :content, presence: true
end
4

0 回答 0