What is the best way to return multiple tags from a Rails Helper?

后端 未结 5 1464
梦如初夏
梦如初夏 2021-02-02 09:19

I want to create a hidden field and create a link in one helper and then output both to my erb.

<%= my_cool_helper \"something\", form %>

5条回答
  •  囚心锁ツ
    2021-02-02 09:50

    So far the best I have come up with is:

    def my_cool_helper(name, form)
      out = capture { link_to name, a_path }
      out << capture { form.hidden_field name.tableize, value => 'something' }
    end
    

    Is there a better way?

提交回复
热议问题