Rails 4: Paperclip and rails_admin "undefined method` attachment_definitions' error"

I use rails_admin and paperclip, but set rails_admin with a model having paperclip attributes has_attached_file gives an error

 undefined method `attachment_definitions' 

I use Rails 4 and rails_admin in the main git file and protected gem attributes.

+7
ruby-on-rails paperclip rails-admin
source share
3 answers

I'm still on rails 3 but ran into the same issue. I am pretty sure this is a problem with the latest clips and rails_admin. I supported clip-to-clip (3.4.2), and everything works.

One more note: I am using ruby โ€‹โ€‹1.9.3

So, for the new rails guys / galls

In your gem file

 gem "paperclip", "3.4.2" 

then bundle update

Not sure if other versions will work, but I know what it does

+8
source share

Are you calling has_attached_file correctly in the model itself?

I had ruby โ€‹โ€‹(1.9.3), Rails (4.0.1), clip (3.5.2) and rails_admin (0.5.0), working without errors. Then I created a new model. He had all the usual staple columns and they should have worked. But I got the same error message.

My problem (duh) was that I neglected setting paperclip in the model itself, but had paperclip columns in my schema. I did not call has_attached_file ... in my model.

 has_attached_file :img... 

I involuntarily recall that rails_admin sniffs some cigarette bells and acts on it. Thus, I had clips similar to the columns that rails_admin detected but never called has_attaached_file, which led to an error. And this error makes sense, in fact there were no descriptions of "attachment_definitions"!

+3
source share

The problem may be the lack of a has_attached_file in your model. However, this is an error in rails_admin (in the factory folder). I sent a transfer request here: https://github.com/sferik/rails_admin/pull/2410

Until then, you can use rails_admin from this branch: https://github.com/drap-hr/rails_admin/tree/v0.7.0-fixes (this is version 0.7.0 with the fix paperclip factory)

+1
source share

All Articles