在Ruby on Rails中,为什么“form_for @story”必须将Story作为RESTful

时间:2021-09-09 12:23:41

It seems that when we use

看来我们用的时候

form_for @story do |f|

then Story has to be a RESTful resource and it has to be

那么Story必须是一个RESTful资源,它必须是

map.resources :stories

in the routes.rb.

在routes.rb中。

Can Story be not RESTful? Can it be a form for non-RESTful data?

故事可能不是RESTful吗?它可以是非RESTful数据的表单吗?

1 个解决方案

#1


Check out rails documentation for form_for.

查看form_for的rails文档。

You can modify the form_for @story and pass in some other options to suit your needs.

您可以修改form_for @story并传入一些其他选项以满足您的需求。

If that doesn't work for you, you can use form_tag instead.

如果这对您不起作用,则可以使用form_tag。

#1


Check out rails documentation for form_for.

查看form_for的rails文档。

You can modify the form_for @story and pass in some other options to suit your needs.

您可以修改form_for @story并传入一些其他选项以满足您的需求。

If that doesn't work for you, you can use form_tag instead.

如果这对您不起作用,则可以使用form_tag。