Forum: Ruby on Rails why does form_for @story has to have Story as RESTful

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eb71c362ddeda80c2668d2575e97bc70?d=identicon&s=25 winter heat (winterheat)
on 2009-05-24 16:04
it seems that when we use

  form_for @story do |f|

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

  map.resources :stories

in the routes.rb?

can Story be not RESTful?  Can it be a form for non-RESTful data?
2a39aed820c125e6db9826fa8180043f?d=identicon&s=25 Denis Haskin (dwhsix)
on 2009-05-24 16:45
(Received via mailing list)
"can Story be not RESTful?  Can it be a form for non-RESTful data?"

Sure.  Keep in mind one of the Rails tenets: "convention over
configuration".

Take a look at the HTML generated by form_for in the various REST
contexts (e.g. new, edit).  *By default* it Does The Right Thing if
you're using RESTful resources.

But there's nothing to stop you from overriding the configuration, e.g.:

    form_for @order, :url => checkout_details_path, :method => :put do
|f|

and having a route to support it.

dwh
This topic is locked and can not be replied to.