title: add attachment to comments(message_part)
body: <p>i basically have message and <code>message_part</code> models.  I installed <code>carrierwave</code>, generated picture uploader, have <code>:picture</code> columns in both <code>message</code> and <code>message_part</code> and I am able to upload image to <code>message</code>.  When i upload image to <code>message_part</code>, this image overwrites all other images and i have the same image in <code>message</code> and <code>message_part</code>.</p>
  
  <p>my Message.rb</p>
  
  <pre><code>class Message &lt; ActiveRecord::Base
    belongs_to :speaker
    has_many :messageparts
    has_many :message_categories
    has_many :categories, through: :message_categories
    mount_uploader :picture, PictureUploader
  end
  </code></pre>
  
  <p>My message_part.rb</p>
  
  <pre><code>class Messagepart &lt; ActiveRecord::Base
    belongs_to :message
    belongs_to :speaker
    mount_uploader :picture, PictureUploader
  end
  </code></pre>
  
  <p>My message_part controller create</p>
  
  <pre><code>def create
      # @message = Message.find(params[:message_id])
      @messagepart = @message.messageparts.create(messagepart_params)
      @messagepart.speaker_id = current_speaker.id
  
      if @messagepart.save
        redirect_to message_path(@message)
      else
        render 'new'
      end
    end
  </code></pre>
  
  <p>my message controller</p>
  
  <pre><code>def create
      @message = current_speaker.messages.build(message_params)
      if @message.save
      redirect_to messages_path
    else
      render 'new'
    end
  
    end
  </code></pre>
  
  <p>my view for message part</p>
  
  <pre><code>&lt;%= simple_form_for([@message, @message.messageparts.build], html: { multipart: true } ) do |f| %&gt;
  
  &lt;%= f.input :contentparttitle, label: "Part Title" %&gt;
  &lt;%= f.input :contentpart, label: "Content Part", :as =&gt; :text, input_html: { :rows =&gt; 10, :class =&gt; "span6" } %&gt;
  &lt;%= f.file_field :picture %&gt;
  &lt;%= f.button :submit, label: "Add Parts", :class =&gt; 'btn-custom' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>my view for message</p>
  
  <pre><code>&lt;%= simple_form_for @message, html: { multipart: true }  do |f| %&gt;
    &lt;%= f.input :title, label: "Message Title"  %&gt;
    &lt;%= f.input :description, label: "Short Description" %&gt;
    &lt;%= f.input :content, :as =&gt; :text, :input_html =&gt; { 'rows' =&gt; 10} %&gt;
    &lt;strong&gt;Category:&lt;/strong&gt;
      &lt;%= f.collection_check_boxes :category_ids, Category.all, :id, :name do |cb| %&gt;
      &lt;% cb.label(class: "checkbox-inline input_checkbox") {cb.check_box(class: "checkbox") + cb.text} %&gt;
      &lt;% end %&gt;
    &lt;%= f.file_field :picture %&gt;
    &lt;%= f.button :submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>my picture uploader</p>
  
  <pre><code>class PictureUploader &lt; CarrierWave::Uploader::Base
  
    # Include RMagick or MiniMagick support:
    # include CarrierWave::RMagick
    # include CarrierWave::MiniMagick
  
    # Choose what kind of storage to use for this uploader:
    storage :file
    # storage :fog
  
    # Override the directory where uploaded files will be stored.
    # This is a sensible default for uploaders that are meant to be mounted:
    def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
  
    # Provide a default URL as a default if there hasn't been a file uploaded:
    # def default_url
    #   # For Rails 3.1+ asset pipeline compatibility:
    #   # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
    #
    #   "/images/fallback/" + [version_name, "default.png"].compact.join('_')
    # end
  
    # Process files as they are uploaded:
    # process :scale =&gt; [200, 300]
    #
    # def scale(width, height)
    #   # do something
    # end
  
    # Create different versions of your uploaded files:
    # version :thumb do
    #   process :resize_to_fit =&gt; [50, 50]
    # end
  
    # Add a white list of extensions which are allowed to be uploaded.
    # For images you might use something like this:
    def extension_white_list
     %w(jpg jpeg gif png)
     end
  
    # Override the filename of the uploaded files:
    # Avoid using model.id or version_name here, see uploader/store.rb for details.
    # def filename
    #   "something.jpg" if original_filename
    # end
  
  end
  </code></pre>