Skip to content

Commit

Permalink
Check for existense of attachment_definitions
Browse files Browse the repository at this point in the history
railsadminteam#1674

This fix in the above PR doesn't work though. Not sure what using "try"
would solve. This actually checks to see if the object resonds to the
method that is missing in some versions of paperclip.
  • Loading branch information
mlins committed Jan 8, 2016
1 parent 992d962 commit 9e4606a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rails_admin/config/fields/factories/paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
extensions = [:file_name, :content_type, :file_size, :updated_at]
model = parent.abstract_model.model
if (properties[:name].to_s =~ /^(.+)_file_name$/) and defined?(::Paperclip) and model.attachment_definitions and model.attachment_definitions.has_key?(attachment_name = $1.to_sym)
if (properties[:name].to_s =~ /^(.+)_file_name$/) and defined?(::Paperclip) and model.respond_to?(:attachment_definitions) and model.attachment_definitions.has_key?(attachment_name = $1.to_sym)
field = RailsAdmin::Config::Fields::Types.load(:paperclip).new(parent, attachment_name, properties)
children_fields = []
extensions.each do |ext|
Expand Down

0 comments on commit 9e4606a

Please sign in to comment.