Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using rails_admin and paperclip but installing rails_admin with a model having paperclip attributes has_attached_file throws an error

undefined method `attachment_definitions'

I am using Rails 4 and rails_admin at master git branch and protected attributes gem.

like image 640
surendar Avatar asked Jul 08 '13 09:07

surendar


2 Answers

I am on rails 3 still but ran into the same issue. I am fairly certain its an issue with the latest paperclip and rails_admin. I backed paperclip down to paperclip (3.4.2) and everything works.

Another thing of note I am using ruby 1.9.3

So for the newer 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 that one does

like image 185
Tyrel Richey Avatar answered Sep 24 '22 17:09

Tyrel Richey


Are you properly calling has_attached_file in the model itself?

I had ruby (1.9.3), Rails (4.0.1), paperclip (3.5.2) and rails_admin (0.5.0) working without error. Then I created a new model. It had all the usual paperclip columns and should have worked. But I got that same error message.

My problem (duh) was that I neglected to configure paperclip in the model itself, but had the paperclip columns in my schema. I wasn't calling has_attached_file ... in my model.

has_attached_file :img...

I loosely recall that rails_admin sniffs certain paperclip smelling columns and acts on it. So I had the paperclip like columns, which rails_admin detected, but never called has_attaached_file resulting in the error. And that error makes sense, there were indeed no "attachment_definitions" to speak of!

like image 31
Tyler Kasten Avatar answered Sep 22 '22 17:09

Tyler Kasten