Rails nested photo file upload form
I have a class Scene, which has_one Photo, and Photo belongs_to Scene. I want to create a form that'll update or create Scene and Photo simultaneously - if Scene already exists, it'll update the Photo with scene_id Scene.id, otherwise, it'll make a new Scene and a new Photo, or if there's no new photo, it'll just update the one Scene field in question ("description").
However I don't have the slightest idea how. I get the feeling it looks nothing li开发者_运维问答ke these other forms.
Oh, and the Photo model is set up to use Attachment-fu.
In Scene Model
accepts_nested_attributes_for :photo
Form
<% form_for @scene do |scene_form| %>
<!-- Fields for scene form -->
<% scene_form.fields_for :photo do |photo_form| %>
<!-- fields for photo form -->
<% end %>
<%= customer_form.submit %>
<% end %>
精彩评论