[英]Rails3 - access to controller create method from not 'new' action
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. 我想创建马铃薯动作,该动作包含形式并使用蔬菜的create方法。
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. 它使用
update
,而不是create
方法。 How can i say Rails to send form to create
action? 我该怎么说Rails发送表单来
create
动作?
您可以使用对应的:url => Vegetable_path
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.