views:

14

answers:

0

I am having some issues with paperclip, on my new page, I have a paperclip file that relates to aonther model. If I don't upload the keynote at the time of creating I can't go back and edit it on the edit page, I'm pretty sure its something todo with the fact that its related to another model.

Here is my form partial

<% form_for([@project, @presentation], :html => { :multipart => true}) do |f| %>
    <%= f.error_messages %>
    <p>
        <%= f.label :title %><br />
        <%= f.text_field :title %>
    </p>
    <p>
        <%= f.label :speaker %><br />
        <%= f.text_field :speaker %>
    </p>
    <p>
        <label for="video">Video</label><br />
        <input name="video" type="file">
    </p>
    <% f.fields_for :keynote do |builder| %>
        <p>
            <%= builder.label :keynote %><br />
            <%= builder.file_field :keynote %>
        </p>
    <% end %>
    <p>
        <%= f.submit "Create" %>
    </p>
<% end %

Here are my models

class Presentation < ActiveRecord::Base
  belongs_to :project
  has_one :video_holder, :dependent => :delete
  has_one :keynote, :dependent => :delete

  accepts_nested_attributes_for :video_holder, :keynote
end

class Keynote < ActiveRecord::Base
  belongs_to :presentation
  has_many :slides, :dependent => :destroy

  has_attached_file :keynote
  after_post_process :convert_keynote_to_slides
end