undefined method `content_type' when editing already-uploaded items (attachment_fu)

My project is for a photographer's portfolio. He's allowed to upload
photographs, which are then displayed on the site. I'm using
attachment_fu. All of this works fine.

Where I'm running into problems is in allowing him to edit the
photographs' attributes later.

I've uploaded a picture of a spider. During the upload I enter the
title as "spider 1". Great, the photo uploads, and if I go to to
admin/index, there it is. Glorious. But oops! I forgot to
capitalize my title! So I head to admin/edit/:photo_id, a form
displays, and I correct my mistake. Then I click Update. And oh
no. :frowning:

NoMethodError in AdminController#update

undefined method `content_type' for #<Photo:0xb67ffbf0>

I've been working on this problem for a while now. Commenting out
everything attachment_fu related in my Photos model is the only way I
can make the edit form work (which of course breaks uploading).

Here is all relevant code:


    class Photo < ActiveRecord::Base

attr_accessible :title, :description, :camera, :time, :date, :iso, :lens,
                      :focal_length, :exposure, :aperture

      has_attachment :content_type => :image,
                     :storage => :file_system,
                     :path_prefix => 'public/photos',
                     :thumbnails => { :thumb => '320x200>' }
      validates_uniqueness_of :filename

      def full_filename(thumbnail = nil)
        file_system_path = (thumbnail ? thumbnail_class :
        File.join(RAILS_ROOT, file_system_path, thumbnail_name_for

      def exifize(photo)
        require 'mini_exiftool'
        @photo = photo
        @exif = MiniExiftool.new "public/photos/#{ @photo.filename }"
        @photo.camera = @exif.model
        @photo.time = @exif.datetimeoriginal.strftime('%I:%M %p')
        @photo.date = @exif.datetimeoriginal.strftime('%B %d, %Y')
        @photo.iso = @exif.iso
        @photo.lens = @exif.lens
        @photo.focal_length = @exif.focal_length
        @photo.aperture = @exif.aperture


    def new
      @photo = Photo.new(params[:photo])

    def create
      @photo = Photo.new(params[:photo])
      if @photo.save
        flash[:notice] = 'Yay!'
        redirect_to :controller => 'admin', :action => :index
        flash[:error] = 'boo...'
        redirect_to :controller => 'admin', :action => :error


    <% form_for :photo, :url => { :controller => 'admin',
                                  :action => 'update',
                                  :id => @photo } do |f| %>

        <%= f.label :title %><br />
        <%= f.text_field :title %>
        <%= f.label :description %><br />
        <%= f.text_area :description %>
        <%= f.label :camera %><br />
        <%= f.text_field :camera %>


        <%= f.submit "Update" %>
    <% end %>

I'm lost. Please help.

Reading documentation thoroughly is always good. A member of
#rubyonrails on freenode helped me out. Since uploading worked fine,
I didn't think to check my model. I had neglected to add the
content_type column. Oops.