form_for but to post to a different action

后端 未结 6 2314
小蘑菇
小蘑菇 2020-12-02 05:08

I want to have a form_for @user, but post to a custom action in the users controller.

How can I do this?

6条回答
  •  鱼传尺愫
    2020-12-02 06:08

    Alternatively the same can be reached using form_tag with the syntax:

    form_tag({controller: "people", action: "search"}, method: "get", class: "nifty_form")
    # => '
    '

    As described in http://guides.rubyonrails.org/form_helpers.html#multiple-hashes-in-form-helper-calls

提交回复
热议问题