开发者

Rails 3: Using Simple_form how do I create a form that do a Post to specialities#create?

开发者 https://www.devze.com 2023-02-07 23:21 出处:网络
Using Simple_form how do I create a form that do a Post to specialities#create? I tried this: &开发者_开发问答lt;%= simple_form_for @course_group, :html =>

Using Simple_form how do I create a form that do a Post to specialities#create?

I tried this:

&开发者_开发问答lt;%= 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. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消