2

I am trying to setup a multi language form upload in activeadmin. My goal is to be able to upload a different pdf file depending on the locale (french and english). I created a "Resume" model and setup the paperclip and translate attributes as described in the documentation of ‘paperclip-globalize'

Every time I try to upload a file I got the following error: "unknown attribute 'resume' for Resume::Translation" (I have created the resume_translations table)

How can I make rails to understand that ‘resume’ attribute should be understood as paperclip attribute in the translation table ? How should I defined ‘permit_params’ in my admin file ?

Thanks for your help !

My activeadmin file:

permit_params :id, translations_attributes: [
                     :id, :locale, :resume
                   ]

form do |f|
  f.semantic_errors *f.object.errors.keys

  f.inputs 'Resume' do
    f.translated_inputs 'Translated fields', switch_locale: false do |t|
      t.input :resume, as: :file,
    end
  end

  f.actions
end

My Resume model:

class Resume < ActiveRecord::Base
  belongs_to :attachable, polymorphic: true
  has_attached_file :resume,
                path: ':rails_root/public/system/:attachment/:id/:filename',
                url:  '/system/:attachment/:id/:locale/:filename',
                default_url: '/assets/images/default_media/:style/missing.png'

  validates_attachment_content_type :resume, content_type: %w(application/pdf)

  translates :resume_file_name, 
             :resume_content_type, 
             :resume_file_size, 
             :resume_updated_at, 
             fallbacks_for_empty_translations: true
  active_admin_translates :resume_file_name, 
                          :resume_content_type, 
                          :resume_file_size, 
                          :resume_updated_at, 
                          fallbacks_for_empty_translations: true
end

My project:

  • Rails 4.2
  • Ruby 2.2.0
  • Paperclip 4.2.1
  • Globalize 5.0.1
  • Paperclip-globalize 2.2.0
  • Activeadmin-globalize
anthony
  • 640
  • 1
  • 10
  • 32

0 Answers0