OSX Leopard - undefined method `has_attached_file'

234 views
Skip to first unread message

discoposse

unread,
Jun 11, 2009, 3:29:44 PM6/11/09
to Paperclip Plugin
Ok...I've hit the wall on this.

OS X 10.5.7
Ruby 1.8.6
rails 2.3.2
paperclip 2.1.2
thoughtbot-paperclip 2.2.9.1

Followed the coding process here: http://railscasts.com/episodes/134-paperclip
but I'm using the gem rather than the plugin

Generates this:

NoMethodError in ItemsController#index

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

I've also added require 'paperclip' to my environment.rb and confirmed
by running script/console that require 'paperclip' returns []

Any ideas?

Nick Quaranto

unread,
Jun 11, 2009, 3:36:11 PM6/11/09
to papercli...@googlegroups.com
You have two versions of paperclip installed? What's your `rake gems` look like? Does it show paperclip as installed or frozen?

Also, if you could paste some code here in the list or throw it on Gist, that would probably help more. http://gist.github.com

discoposse

unread,
Jun 11, 2009, 4:09:53 PM6/11/09
to Paperclip Plugin
Sorry about that. That probably confused things. I did have 2 gems
installed.

I've removed the paperclip 2.1.2 and still get the same results.

I've put up the code from the files. It's dead simple: git://gist.github.com/128194.git

My setup was:

1. Install thoughtbot-paperclip gem (sudo gem install)
2. Install ImageMagick (confirmed to be working)
3. Generate scaffold description:string price:string
4. Generate paperclip migration
5. Run migrations

Confirmed the table contains my fields and the photo_ fields

On Jun 11, 12:36 pm, Nick Quaranto <n...@quaran.to> wrote:
> You have two versions of paperclip installed? What's your `rake gems` look
> like? Does it show paperclip as installed or frozen?
>
> Also, if you could paste some code here in the list or throw it on Gist,
> that would probably help more.http://gist.github.com

Marlon Moyer

unread,
Jun 11, 2009, 4:29:10 PM6/11/09
to papercli...@googlegroups.com
can you instantiate a new Item object from script/console?

discoposse

unread,
Jun 11, 2009, 6:00:10 PM6/11/09
to Paperclip Plugin

Same error

>> @item = Item.new
NoMethodError: undefined method 'has_attached_file' for #<Class:
0x18c9424>

I know that this is probably something dead simple...but somehow it's
eluding me

Marlon Moyer

unread,
Jun 11, 2009, 6:13:02 PM6/11/09
to papercli...@googlegroups.com
ok, try this: http://gist.github.com/128269

you should be able to do this without an error. If you are getting an
error, something is probably wrong with your paperclip install. Are
you running the default ruby on osx?

discoposse

unread,
Jun 11, 2009, 6:18:23 PM6/11/09
to Paperclip Plugin
:(

Same result. NoMethodError: undefined method 'has_attached_file' for
#<Class:0x183196c>

I have upgraded the ruby environment (I heard that the one shipped is
a problem). I'll try to remove the gem and re-install to see if I get
any better results.

let me know if there are any other suggestions.

Marlon Moyer

unread,
Jun 11, 2009, 6:21:41 PM6/11/09
to papercli...@googlegroups.com
which environment are you using? REE?

Marlon Moyer

unread,
Jun 11, 2009, 6:23:25 PM6/11/09
to papercli...@googlegroups.com
is this the only gem you're having trouble with. Are you using any
other gems?

Do the 'gem' and 'ruby' command both point to the same environment?


On Jun 11, 2009, at 5:00 PM, discoposse wrote:

>
>

discoposse

unread,
Jun 11, 2009, 8:44:40 PM6/11/09
to Paperclip Plugin
All other gems are working ok. Environment is traditional RoR (no
REE). Mongrel etc...

Marlon Moyer

unread,
Jun 11, 2009, 9:25:34 PM6/11/09
to papercli...@googlegroups.com
you said you rebuilt the environment, what do the following commands show:

which gem

which ruby

which irb
--
Marlon

Andreas

unread,
Jun 12, 2009, 3:24:41 AM6/12/09
to Paperclip Plugin
Did you remember to write:

requires 'paperclip' (or requires ' Paperclip' or whatever)

in the envireonment.rb???

discoposse

unread,
Jun 12, 2009, 12:53:39 PM6/12/09
to Paperclip Plugin
I've fixed the issue by using the plugin rather than the gem. Not
really a fix, I would much rather use the gem. If I get a chance to
get past this I'll post the solution. Thanks for all your help :)

Jonathan Yurek

unread,
Jun 16, 2009, 8:11:42 AM6/16/09
to papercli...@googlegroups.com
What does your environment.rb look like? Can I see the config.gem line
you had that was specifying paperclip? It should be able to work
perfectly fine from a gem (although I'm glad it works as a plugin for
you), so I have to think there may be a config issue somewhere.
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
organic brains. digital solutions.

617.482.1300 x114
http://www.thoughtbot.com/

kilari

unread,
Jul 6, 2009, 1:05:32 PM7/6/09
to Paperclip Plugin
When I add require 'paperclip' to my environment.rb it doesn't work,
but when I add it as config.gem or as a plugin it work's fine. Any
specific reason. I have tried all possible tries.If I add it in the
model then also it work fine.:(


irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'paperclip'
=> true
irb(main):003:0>

Thanks,
Kilari Vamsi.

Ryan McGeary

unread,
Jul 8, 2009, 11:14:29 AM7/8/09
to papercli...@googlegroups.com
Kilari,

My guess is that you added require 'paperclip' to the top of your environment.rb instead of the bottom.  Paperclip automatically adds methods to ActiveRecord::Base if the ActiveRecord constant is defined.  ActiveRecord isn't loaded until after the initialization that is done in environment.rb.

More importantly, why are you trying to avoid config.gem or plugin?

-Ryan

kilari

unread,
Jul 9, 2009, 6:09:06 AM7/9/09
to Paperclip Plugin
Ryan,

I have tried all the possible combination's but with fail to use it as
a gem.There is no particular reason to use it as a gem but was just
trying to make it work on the production server as it works fine on
the dev machine as a gem.

Thanks,
Kilari.
Reply all
Reply to author
Forward
0 new messages