Ruby on rails Rails:如何将表单发布到另一个控制器操作
我知道你通常应该在rails中使用new/create和edit/update之间的链接,但我有一个例子需要其他东西。我是否可以实现同样的连接 我有一个模型表单,我希望它发布数据(类似于新视图如何发布到创建操作) 这是我的表格Ruby on rails Rails:如何将表单发布到另一个控制器操作,ruby-on-rails,ruby,ruby-on-rails-3,forms,Ruby On Rails,Ruby,Ruby On Rails 3,Forms,我知道你通常应该在rails中使用new/create和edit/update之间的链接,但我有一个例子需要其他东西。我是否可以实现同样的连接 我有一个模型表单,我希望它发布数据(类似于新视图如何发布到创建操作) 这是我的表格 <div id="new-job"> <%= form_for(@job) do |f| %> <% if @job.errors.any? %> <div id="error_explanation"
<div id="new-job">
<%= form_for(@job) do |f| %>
<% if @job.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@job.errors.count, "error") %> prohibited this job from being saved:</h2>
<ul>
<% @job.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :location %><br />
<%= f.text_field :location %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_area :description %>
</div>
<div class="actions">
<%= f.submit "create job", id: "submit-job", class: "button small radius" %>
<%= link_to "go back", jobs_path, class: "button small radius secondary" %>
<div id="new-job-errors"> </div>
</div>
<% end %>
</div>
禁止保存此作业:
使用:url
选项
= form_for @job, :url => company_path, :html => { :method => :post/:put }
=form\u for@job,:url=>company\u path,:method=>:post/:put
对于任何收到此错误的人未定义的NilClass:Class的方法模型\u名称使用此:=form\u for job.new,url:company\u path,method::post