Odd error after Rails 2.0.2 > 2.1

19 views
Skip to first unread message

miles.s...@gmail.com

unread,
Jul 18, 2008, 9:25:03 AM7/18/08
to Paperclip Plugin
Peoples -
My attachments were working flawlessly up until recently when I
finally went through the process of upgrading to Rails 2.1. I'm sure
I've missed something, or done something wrong. I am hoping someone
will be able to point out my ignorance.
I have 'tickets', which have many 'uploads' (as uploadable --
polymorphic) which have the attached file. I think it may be
pertinent to know that I'm running on SQL Server 2000. The following
is the error I'm getting when a page that would list the uploaded
files:

### Error output

Showing tickets/_files.rhtml where line #12 raised:

undefined method `quoted_table_name' for Paperclip::Attachment:Class

Extracted source (around line #12):

9: <div class="metaBody">
10: <span class="metaField">Files</span>
11: <ul id="file_list">
12: <%= render :partial => 'file', :collection =>
@ticket.files %>
13: <li>
14: <form class="inline" id="file_form" enctype="multipart/
form-data" action="/uploads.js" method="post" target="background-
uploader">
15: <label>File</label>

Full Trace:

vendor/rails/activerecord/lib/active_record/reflection.rb:137:in
`quoted_table_name'
vendor/rails/activerecord/lib/active_record/associations/
has_many_association.rb:79:in `construct_sql'
vendor/rails/activerecord/lib/active_record/associations/
association_collection.rb:8:in `initialize'
vendor/rails/activerecord/lib/active_record/associations.rb:1128:in
`new'
vendor/rails/activerecord/lib/active_record/associations.rb:1128:in
`attachments'
app/models/ticket.rb:311:in `files'
app/views/tickets/_files.rhtml:12:in
`_run_erb_47app47views47tickets47_files46rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/
compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/
compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/partial_template.rb:20:in
`render'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
`benchmark'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:
8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
`benchmark'
vendor/rails/actionpack/lib/action_view/partial_template.rb:19:in
`render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in
`render_template'
vendor/rails/actionpack/lib/action_view/partials.rb:110:in
`render_partial'
vendor/rails/actionpack/lib/action_view/base.rb:273:in `render'
app/views/tickets/show.html.erb:79:in
`_run_erb_47app47views47tickets47show46html46erb'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/
compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/
compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in
`render_template'
vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
vendor/rails/actionpack/lib/action_controller/base.rb:1108:in
`render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:865:in
`render_with_no_layout'
vendor/rails/actionpack/lib/action_controller/base.rb:880:in
`render_with_no_layout'
vendor/rails/actionpack/lib/action_controller/layout.rb:251:in
`render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:
8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
app/controllers/application.rb:19:in `render'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:131:in
`send'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:131:in
`custom'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:160:in
`call'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:160:in
`respond'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:154:in
`each'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:154:in
`respond'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:107:in
`respond_to'
app/controllers/tickets_controller.rb:37:in `show'
vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:1162:in
`perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:580:in
`call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:601:in
`run_before_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:398:in `call'
vendor/rails/actionpack/lib/action_controller/filters.rb:398:in `call'
vendor/rails/actionpack/lib/action_controller/filters.rb:598:in
`run_before_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:578:in
`call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:573:in
`perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in
`perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:
13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/query_cache.rb:33:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in
`cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:
12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in
`process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:569:in
`process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:
130:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in
`handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in
`dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in
`dispatch'
/usr/lib/ruby/gems/1.8/gems/ebb-0.2.1/ruby_lib/rack/adapter/rails.rb:
51:in `serve_rails'
/usr/lib/ruby/gems/1.8/gems/ebb-0.2.1/ruby_lib/rack/adapter/rails.rb:
66:in `call'
/usr/lib/ruby/gems/1.8/gems/ebb-0.2.1/ruby_lib/ebb.rb:53:in `process'
/usr/lib/ruby/gems/1.8/gems/ebb-0.2.1/ruby_lib/ebb.rb:36:in
`start_server'
/usr/lib/ruby/gems/1.8/gems/ebb-0.2.1/ruby_lib/ebb/runner.rb:120:in
`run'
/usr/lib/ruby/gems/1.8/gems/ebb-0.2.1/bin/ebb_rails:4
/usr/bin/ebb_rails:19:in `load'
/usr/bin/ebb_rails:19

Thanks for looking! I'm going to keep researching. If I come across
a solution, I'll leave an update.

MilesZS

miles.s...@gmail.com

unread,
Jul 18, 2008, 9:39:54 AM7/18/08
to Paperclip Plugin
Update: The problem is not at all what I thought it was, but maybe
someone here can, again, clear up my own ignorance.

We previously used a different method for 'attaching' files (it was
more describing where on the network one could find the files, rather
than actual uploads). The model is called Attachment. It seems that
trying to retrieve these old attachments is causing the above error,
somehow. So, it's actually mostly unrelated to the class that
actually utilizes Paperclip. At first I suspected some sort of class
name collision, but that would be odd considering namespacing.

I know that is not much to go on. Again, I'll leave an update if I
find a solution. Thanks!

MilesZS


On Jul 18, 9:25 am, "miles.sterr...@gmail.com"

miles.s...@gmail.com

unread,
Jul 18, 2008, 4:28:50 PM7/18/08
to Paperclip Plugin
The issue was resolved by renaming my Attachment model class and
related classes, leading me to believe there was some sort of conflict
between Paperclip::Attachment and my model named Attachment. Simply
renaming the association did not work. This appeared after upgrading
from Rails 2.0.2 to Rails 2.1.

Should I file a bug report?

Thanks, Thoughtbot, for Paperclip (and Shoulda). They have made my
job easier.

MilesZS

coolfeind

unread,
Jul 21, 2008, 12:22:46 AM7/21/08
to Paperclip Plugin
I had this EXACT same problem and renaming the join table from
attachments to something else fixed it... only after wasting the
entire weekend trying to work around it.

On Jul 18, 3:28 pm, "miles.sterr...@gmail.com"

Scott

unread,
Jul 24, 2008, 11:51:17 AM7/24/08
to Paperclip Plugin
I also hit this after the upgrade to 2.1. Took a while to figure out
Paperclip didn't like my model named 'Attachments'.

Olafski

unread,
Jul 25, 2008, 7:50:40 AM7/25/08
to Paperclip Plugin
Not to be uptight about this, but it's not exactly the Rails
convention to pluralize your model name. I'm sure you have a good
reason to do so though :)
Reply all
Reply to author
Forward
0 new messages