Because you're to cool not to fork the release candidate

Posts Tagged: paperclip


One of my clients’ site,, is undergoing a full overhaul currently and occupies a lot of my free time. I figure it deserves the occasional blog for updates.


Gnartifact is getting a brand new video archiving form. Before, the site grabbed a lot of data from the Vimeo and YouTube APIs from the Rails backend. In this version, all API calls are done client-side using jQuery. This increases performance and accuracy of archiving.

Select default thumbnails is now even easier as you can now upload your own thumbnails, and all past thumbnails are saved to be chosen from at any point. Customization is the name of the game for this version. Paperclip still powers image uploading.

With the addition of many more video attributes, the archive form is broken into tabs. This makes organization and user workflow much simpler, and makes it easy to enable or disable features on the fly.

Major changes is the upgrade to Rails 3.1 from Rails 2.3. Production server will run on Phusion Passenger instead of a Mongrel cluster. Hosting company will be switched to my own reseller account. RVM is implemented now right in development. A local Git server and Capistrano will be used for deployment. The complete custom administrative end has been replaced with the ActiveAdmin gem, which I really recommend you check out. 

As always, NewRelic will be used for server monitoring. 

More updates to come soon

Build nested field only for new entry

I have a nested form in which I would like the form fields to only appear once for uploading a new image, then display the existing images, without any sort of CRUD capability. In essence, on the edit page, just give the option to add images, but not delete or update.

The relationship is a video has many video_images, which use paperclip for has_attached_file :image I’m trying the following in my controller now:

  # GET /videos/new
# GET /videos/new.json
def new
@video =
@newthumbnail =

do |format|
.html # new.html.erb
.json { render json: @video }

And this in my view:

    <%= f.fields_for @newthumbnail do |u| %>
<%= u.label :image, "Upload New Thumbnail" %> <br />
<%= u.file_field :image, :class => "image_uploader" %>
<% end %>
Or select a previous thumbnail
    <div id="previous_thumbnails">
      <!-- These will ultimately be dynamically generated as the existing image associations -->
      <div class="previous_thumbnail" rel="1">
        <img src="http:/
/" />
      <div class="
selected previous_thumbnail" rel="2">
        <img src="" />
      <div class="
previous_thumbnail" rel="3">
        <img src="" />
      <div class="
previous_thumbnail" rel="4">
        <img src="" />

But I end up with the following error:

unknown attribute: video_image

Which tells me that somewhere, there’s a mistranslation of singularity vs plurality. I can see why Rails would singularize it, as it is, in fact, a single entry. However, even overriding the name of the file field, and making name="video[video_image][image]" into name="video[video_images][image]", I get an error like so:

VideoImage(#39741260) expected, got Array(#9591480)

With params sent:

"video_images"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x000000054f1078 @original_filename="Bill OneManBand.jpg",
@headers="Content-Disposition: form-data; name=\"video[video_images][image]\"; filename=\"Bill OneManBand.jpg\"\r\nContent-Type: image/jpeg\r\n",

So where am I going wrong? I feel like I may be taking the wrong approach to this…