has_attached_file: undefined method

391 views
Skip to first unread message

Guitaronin

unread,
Jul 10, 2008, 7:07:15 PM7/10/08
to Paperclip Plugin
I've just installed Paperclip on an app I'm developing on Heroku.
When trying to create a new record with a .jpg file attached, I get
the error below. No one else seems to have posted this problem, so I
hope I'm doing something wrong.

Any help = much appreciated!

----------------------------------------------------------------------------------------------------
NoMethodError in ProfilesController#index

undefined method `has_attached_file' for #<Class:0xb75053f4>
----------------------------------------------------------------------------------------------------

<b>My code is as follows:</b>

<b>Model:</b>

class Profile < ActiveRecord::Base
has_attached_file :avatar,
:styles => { :medium => "300x300>",
:thumb => "100x100>" }
end


<b>Controller:</b>

def new
@profile = Profile.new

respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @profile }
end
end

def create
@profile = Profile.new(params[:profile])

respond_to do |format|
...

end
end


<b>View:</b>

<% form_for(@profile, :html => { :multipart => true }) do |f| %>
<b>Profile Pic</b>
<%= f.file_field :avatar %>
<%= f.submit "Create" %>
<% end %>

Guitaronin

unread,
Jul 13, 2008, 4:26:58 PM7/13/08
to Paperclip Plugin
In case anyone else runs into this, I wanted to post my resolution.
Heroku installs Paperclip as a Gem rather than a plugin (I didn't
notice because Heroku puts both in the 'vendors' folder). Anywho, it
was simply a matter of adding "require 'paperclip'" to my model.

Now if I can just figure out why resized images aren't showing up. :(
Reply all
Reply to author
Forward
0 new messages