title: Paperclip Error: model missing required attr_accessor for 'avatar_file_name'
body: <p>I then want to use Paperclip to have photos for each Listing. I added the appropriate code to the listings show.html.erb, the listing.rb model, the listings_controller.rb and the _form.html.erb partial. </p>
  
  <p>When I try uploading an image for the Listing I get this error:</p>
  
  <pre><code>Paperclip::Error in ListingsController#update
  Listing model missing required attr_accessor for 'avatar_file_name'
  </code></pre>
  
  <p>Line 44 of listings_controller:</p>
  
  <pre><code>def update
   respond_to do |format|
    if @listing.update(listing_params)
      format.html { redirect_to @listing, notice: 'Listing was successfully updated.' }
      format.json { head :no_content }
    else
  </code></pre>
  
  <p>A few things to try: namely adding some code to the listing.rb model to make the acceptable images for the :avatar more robust. Here is what several stackoverflow posts mentioned adding to the listing.rb model:</p>
  
  <pre><code>validates_attachment_content_type :avatar, :content_type =&gt; %w(image/jpeg image/jpg image/png) 
  </code></pre>
  
  <p>Unfortunately I still get the same error when I attach an image. When I don't attach an image my default image is loaded fine and the listing is created properly. </p>
  
  <p>My Listing model:</p>
  
  <pre><code>class Listing &lt; ActiveRecord::Base
    has_attached_file :avatar, :styles =&gt; { :medium =&gt; "150x", :thumb =&gt; "100x100&gt;" },   :default_url =&gt; "default.jpg"
    validates_attachment_content_type :avatar, :content_type =&gt; %w(image/jpeg image/jpg image/png) 
  end
  </code></pre>
  
  <p>My _form.html.erb partial:</p>
  
  <pre><code>&lt;%= form_for @listing, :html =&gt; { :multipart =&gt; true } do |f| %&gt;
    &lt;% if @listing.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@listing.errors.count, "error") %&gt; prohibited this listing from being saved:&lt;/h2&gt;
  
        &lt;ul&gt;
        &lt;% @listing.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;div class="form-group"&gt;
      &lt;%= f.label :name %&gt;&lt;br&gt;
      &lt;%= f.text_field :name, class: "form-control" %&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :company %&gt;&lt;br&gt;
      &lt;%= f.text_field :company, class: "form-control" %&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :email %&gt;&lt;br&gt;
      &lt;%= f.text_field :email, class: "form-control" %&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :phone %&gt;&lt;br&gt;
      &lt;%= f.text_field :phone, class: "form-control" %&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :avatar %&gt;&lt;br&gt;
      &lt;%= f.file_field :avatar, class: "form-control" %&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.submit class: "btn btn-primary" %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>My listings_controller.rb controller:</p>
  
  <pre><code> def update
      respond_to do |format|
        if @listing.update(listing_params)
          format.html { redirect_to @listing, notice: 'Listing was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: 'edit' }
          format.json { render json: @listing.errors, status: :unprocessable_entity }
        end
      end
    end
  ...
  def listing_params
     params.require(:listing).permit(:name, :company, :email, :phone, :avatar)
  end
  </code></pre>
  
  <p>And my schema.rb file</p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20140329174335) do
  
    create_table "listings", force: true do |t|
      t.string   "name"
      t.string   "company"
      t.string   "email"
      t.string   "phone"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  
  end
  </code></pre>
  
  <p>EDIT: Adding console output after running $rails generate paperclip listing avatar</p>
  
  <p>(I need 10 reputation points to put in post so you have to settle for link <a href="http://i.imgur.com/c8KGTa3.png">http://i.imgur.com/c8KGTa3.png</a>)</p>