Rails Nested Forms With Images

后端 未结 2 1647
日久生厌
日久生厌 2021-02-08 02:34

So I\'m building a nested form with an Campaigns model and a Sites model where Campaigns has_many Sites. In my Campaigns form I have:

<%= f.fields_for :sites          


        
2条回答
  •  悲&欢浪女
    2021-02-08 03:06

    From the form helper object (in your case builder and f) you should be able to access the model object and the url your looking for like this:

    <%= image_tag f.object.image_url(:thumb) %>
    

    The image in image_url depends on how you named the attribute, but for your sample this should be correct.

提交回复
热议问题