How to set up form for a hash in Rails?

前端 未结 3 582
悲哀的现实
悲哀的现实 2021-02-06 01:47

I have some data associated with a model that is in a hash. The hash is generated in the controller: @hash.

What is the proper way to create a form for this

3条回答
  •  广开言路
    2021-02-06 02:28

    My answer is not strictly on topic but I really recommend you to take a look at http://railscasts.com/episodes/219-active-model. You could use ActiveModel APIs to simulate a model object with Rails 3. Doing that you could simply do something like

    <%= form_for(@object) %>
    

    and leaving the populating of your object to Rails APIs.

提交回复
热议问题