开发者

Rails3 - access to controller create method from not 'new' action

开发者 https://www.devze.com 2023-03-22 23:30 出处:网络
I have controller vegetable. It has standart new and create methods. I want to create potato action, that contain form and using vegetable\'s create method.

I have controller vegetable. It has standart new and create methods.

I want to create potato action, that contain form and using vegetable's create method.

In potato view i have this:

= form_for @vegetable, :url => '/vegetable/create/' do |f|
  = f.text_field :color
  = f.submit "Save"

When i press save, i get error

ActiveRecord::RecordNotFound in VegetablesController#update  
Couldn't 开发者_如何转开发find Vegetable with ID=create

It uses update, not create method. How can i say Rails to send form to create action?


you sould use corresponded :url => vegetable_path

0

精彩评论

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