At the moment if an object is passed to form_for the action and the method 
to which the form is submitted is hardcoded. It would be awesome to allow 
an object to determine its own target. The code for this is located in the 
method `def apply_form_for_options!(record, object, options)` in file 
`actionview/lib/action_view/helpers/form_helper.rb` . The responsible line 
is:
```ruby
action, method = object.respond_to?(:persisted?) && object.persisted? ? 
[:edit, :patch] : [:new, :post]
```

Maybe if the object responds to something like `target_action_and_method` 
that returns a similar array with the default given above it would be nice.

It would hopefully prevent code like written at 
https://github.com/bterkuile/record_collection/blob/cc8376b021a1ddd3ba44046ab530d6ea34b660ce/lib/record_collection/rails/form_helper.rb

Thanks!

Benjamin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to