Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 静态页面#resume中的命名错误(未定义的方法` resume#路径';)_Ruby On Rails_Ruby_Path - Fatal编程技术网

Ruby on rails 静态页面#resume中的命名错误(未定义的方法` resume#路径';)

Ruby on rails 静态页面#resume中的命名错误(未定义的方法` resume#路径';),ruby-on-rails,ruby,path,Ruby On Rails,Ruby,Path,它以前工作得很好,但我现在遇到了这个错误 当我尝试单击或浏览路径/resume 下面是我如何在routes.rb中使用它的 match '/resume', to: 'static_pages#resume' 然后,这里是静态页面控制器 def resume if signed_in? @resume = current_user.resumes.build end end 下面是导致错误的静态\u pages\resume.html视图 <% if signed

它以前工作得很好,但我现在遇到了这个错误

当我尝试单击或浏览路径
/resume

下面是我如何在routes.rb中使用它的

match '/resume', to: 'static_pages#resume'
然后,这里是静态页面控制器

 def resume
    if signed_in?
    @resume = current_user.resumes.build
  end
end
下面是导致错误的静态\u pages\resume.html视图

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

{:multipart=>true}do | f |%>
添加您的文件:

它告诉我是这行代码引起的。关于如何解决这个问题有什么想法吗?

您只有/resume的路线。您应该为表单的POST方法添加路由

将此添加到您的路线中

match '/resumes' => 'static_pages#create', :via => [:post]


应该是“静态页面#创建”还是“静态页面#简历”?我尝试添加
:via=>[:post]
,但它给出了一个错误:
没有与[GET]“/resume”匹配的路由。
您需要两条路由。一个用于显示表单的get方法,另一个用于提交表单的post方法。您还需要两个控制器操作。如何定义get部分以显示表单?我以后会担心这篇文章,你写的路线和行动足以让我参与其中。但在你看来,你是在为(@resume)调用form_。这将尝试创建表单操作url,但您的路由缺少该url。这是导致错误的原因所以我可以把这两个放在路线上
match'/resumes'=>'静态页面#resume'
match'/resumes'=>'静态页面#创建',:via=>[:post]
resources :resumes #This will need resumes controller and actions