gpt4 book ai didi

ruby-on-rails - rails 3 : Using Simple_form how do I create a form that do a Post to specialities#create?

转载 作者:行者123 更新时间:2023-12-04 01:21:14 25 4
gpt4 key购买 nike

使用 Simple_form 如何创建一个表单来发布到专业#create?

我试过这个:

<%= simple_form_for @course_group, :html => 
{ :method => 'post',
:action=> 'create',
:controller=>'specialities' }

但是创建的表单是:
<form accept-charset="UTF-8" 
action="/course_groups"
class="simple_form course_group"
controller="specialities"
id="new_course_group"
method="post">

我的预期是:
<form accept-charset="UTF-8" 
action="/specialities"
class="simple_form course_group"
controller="specialities"
id="new_course_group"
method="post">

最佳答案

尝试使用 :url选项,而不是包含 :action & :controller就在 html 哈希中。我会将您的示例重新编写为:

<%= simple_form_for @course_group, 
:url => url_for(:action => 'create', :controller => 'specialities'),
:method => 'post' do |f| %>

查看实际 form_for引用 http://api.rubyonrails.org

关于ruby-on-rails - rails 3 : Using Simple_form how do I create a form that do a Post to specialities#create?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4855801/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com