[英]Rails 3: Using Simple_form how do I create a form that do a Post to specialities#create?
Using Simple_form how do I create a form that do a Post to specialities#create? 使用Simple_form如何创建一个表单来发布专业#create?
I tried this: 我试过这个:
<%= simple_form_for @course_group, :html =>
{ :method => 'post',
:action=> 'create',
:controller=>'specialities' }
But the form that is created is: 但是创建的表单是:
<form accept-charset="UTF-8"
action="/course_groups"
class="simple_form course_group"
controller="specialities"
id="new_course_group"
method="post">
What I expected is: 我的期望是:
<form accept-charset="UTF-8"
action="/specialities"
class="simple_form course_group"
controller="specialities"
id="new_course_group"
method="post">
Try using the :url
option, instead of including :action
& :controller
right in the html hash. 尝试使用
:url
选项,而不是在html哈希中包含:action
& :controller
right。 I would re-write your example as: 我会把你的例子重写为:
<%= simple_form_for @course_group,
:url => url_for(:action => 'create', :controller => 'specialities'),
:method => 'post' do |f| %>
Check out the actual form_for
reference in http://api.rubyonrails.org 查看http://api.rubyonrails.org中的实际
form_for
参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.