title: gem cocoon work locally but not in production
body: <p>I did alot of research to make this work. but nothing solved mine
  link_to_add_association not working in heroku
  gem &quot;cocoon&quot;</p>
  <pre><code>&lt;%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %&gt;
    &lt;%= render &quot;devise/shared/error_messages&quot;, resource: resource %&gt;
      &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :first_name ,&quot;First Name (required)&quot;%&gt;
      &lt;%= f.text_field :first_name, autofocus: true , :size=&gt;&quot;50&quot;, required: &quot;true&quot;,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf007; Your First Name&quot;),id: &quot;someId&quot;%&gt;
    &lt;/div&gt;&lt;br&gt;
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :last_name ,&quot;Last Name (required)&quot;%&gt;
      &lt;%= f.text_field :last_name , :size=&gt;&quot;50&quot;, required: &quot;true&quot;,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf007; Your Last Name&quot;),id: &quot;someId&quot;%&gt;
    &lt;/div&gt;&lt;br&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :phone ,&quot;Phone (required)&quot;%&gt;
      &lt;%= f.text_field :phone , :size=&gt;&quot;50&quot;, required: &quot;true&quot;,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf095; phone&quot;),id: &quot;phoneNumber&quot;%&gt;
    &lt;/div&gt;&lt;br&gt;
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :address ,&quot;Address (required)&quot;%&gt;
      &lt;%= f.text_field :address , :size=&gt;&quot;50&quot;, required: &quot;true&quot;,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf041; Address&quot;),id: &quot;searchTextField&quot;%&gt;
    &lt;/div&gt;&lt;br&gt;
  
    
   
  
    &lt;div class=&quot;field&quot;&gt;&lt;br&gt;
  
       &lt;p class=&quot;address&quot;&gt; &lt;%= link_to_add_association &quot;Add more Addresses and Phone numbers&quot;, f,:addresses, partial: 'address_fields' %&gt;&lt;/p&gt;
      &lt;/div&gt; 
        &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :image ,&quot;Add Profile Picture&quot;%&gt; &lt;%= f.file_field :image %&gt;
     
   &lt;/div&gt;
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :email %&gt;
      &lt;%= f.email_field :email, autocomplete: &quot;email&quot; ,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf0e0; Your email&quot;)%&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :password %&gt;
      &lt;% if @minimum_password_length %&gt;
      &lt;em&gt;(&lt;%= @minimum_password_length %&gt; characters minimum)&lt;/em&gt;
      &lt;% end %&gt;&lt;br /&gt;
      &lt;%= f.password_field :password, autocomplete: &quot;new-password&quot; ,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf023 Add a Password&quot;)%&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :password_confirmation %&gt;&lt;br /&gt;
      &lt;%= f.password_field :password_confirmation, autocomplete: &quot;new-password&quot; ,class: &quot;textbox&quot;,placeholder: raw(&quot;&amp;#xf023 Password Confirmation&quot;)%&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;actions&quot;&gt;
      &lt;%= f.submit &quot;Sign up&quot; %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  
  &lt;%= render &quot;devise/shared/links&quot; %&gt;
  
  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  
  &lt;script src=&quot;https://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery-1.8.3.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.62/jquery.inputmask.bundle.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://maps.googleapis.com/maps/api/js?key=AIzaSyA-ATN59uXNYOqQoVajiXKhhN2vsSc9Xb0&amp;libraries=places&quot;&gt;
  &lt;/script&gt;
  &lt;!-- You forgot closing this --&gt;
         &lt;!-- You forgot starting the below script tag --&gt;
         &lt;script&gt;
         function initialize() {
           var input = document.getElementById('searchTextField');
           var options = {componentRestrictions: {country: 'ca'}};            
           new google.maps.places.Autocomplete(input, options); 
         }         
         google.maps.event.addDomListener(window, 'load', initialize);
         &lt;/script&gt;
  
  &lt;/script&gt;
  </code></pre>
  <p>in _address_fields.html.erb</p>
  <pre><code>&lt;div class=&quot;nested-fields&quot;&gt;
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :name ,&quot;Address&quot;%&gt;
      &lt;%= f.text_field :name , :size=&gt;&quot;50&quot;,class: &quot;textbox&quot; ,id:&quot;searchTextField&quot; ,placeholder: raw(&quot;&amp;#xf041; Address&quot;)%&gt;
      &lt;input id=&quot;address&quot; name=&quot;address&quot; value='' type=&quot;hidden&quot; placeholder=&quot;&quot;&gt;
      &lt;%= f.label :phone ,&quot;Phone&quot;%&gt;
      &lt;%= f.text_field :phone , :size=&gt;&quot;50&quot;,class: &quot;textbox&quot; ,id:&quot;phoneNumber&quot; ,placeholder: raw(&quot;&amp;#xf095; phone&quot;),id: &quot;phoneNumber&quot;%&gt;
      
      &lt;%= link_to_remove_association &quot;Remove address&quot;, f %&gt;&lt;br&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>in application.js</p>
  <pre><code>// This is a manifest file that'll be compiled into application.js, which will include all the files
  // listed below.
  //
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
  // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
  //
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  // compiled file.
  //
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
  // about supported directives.
  //
  //= require jquery
  //= require jquery_ujs
  //= require turbolinks
  //= require bootstrap
  //= require sweetalert2
  //= require sweet-alert2-rails
  //= require sweet-alert-confirm  
  //= require cocoon 
  //= require_tree .
  </code></pre>
  <p>in production.rb</p>
  <pre><code>Rails.application.configure do
    # Settings specified here will take precedence over those in config/application.rb.
  
    # Code is not reloaded between requests.
    config.cache_classes = true
    config.serve_static_files = true
    # config.serve_static_assets = true
    # Eager load code on boot. This eager loads most of Rails and
    # your application in memory, allowing both threaded web servers
    # and those relying on copy on write to perform better.
    # Rake tasks automatically ignore this option for performance.
    config.eager_load = true
  
    # Full error reports are disabled and caching is turned on.
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true
    config.force_ssl = true
    # Enable Rack::Cache to put a simple HTTP cache in front of your application
    # Add `rack-cache` to your Gemfile before enabling this.
    # For large-scale production use, consider using a caching reverse proxy like
    # NGINX, varnish or squid.
    # config.action_dispatch.rack_cache = true
  
    # Disable serving static files from the `/public` folder by default since
    # Apache or NGINX already handles this.
    
  
    # Compress JavaScripts and CSS.
    config.assets.js_compressor = Uglifier.new(harmony: true)
    # config.assets.css_compressor = :sass
  
    # Do not fallback to assets pipeline if a precompiled asset is missed.
    config.assets.compile = true
   
    config.assets.precompile += %w(application.js)
    config.assets.precompile += %w( application.css.scss )
    # Asset digests allow you to set far-future HTTP expiration dates on all assets,
    # yet still be able to expire them through the digest params.
    config.assets.digest = true
  
    # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
  
    # Specifies the header that your server uses for sending files.
    # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
  
    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
    # config.force_ssl = true
  
    # Use the lowest log level to ensure availability of diagnostic information
    # when problems arise.
    config.log_level = :debug
  
    # Prepend all log lines with the following tags.
    # config.log_tags = [ :subdomain, :uuid ]
  
    # Use a different logger for distributed setups.
    # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
  
    # Use a different cache store in production.
    # config.cache_store = :mem_cache_store
  
    # Enable serving of images, stylesheets, and JavaScripts from an asset server.
    # config.action_controller.asset_host = 'http://assets.example.com'
  
    # Ignore bad email addresses and do not raise email delivery errors.
    # Set this to true and configure the email server for immediate delivery to raise delivery errors.
    # config.action_mailer.raise_delivery_errors = false
  
    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
    # the I18n.default_locale when a translation cannot be found).
    config.i18n.fallbacks = true
  
    # Send deprecation notices to registered listeners.
    config.active_support.deprecation = :notify
  
    # Use default logging formatter so that PID and timestamp are not suppressed.
    config.log_formatter = ::Logger::Formatter.new
  
  
  
  end
  </code></pre>
  <p>in application.css.scss</p>
  <pre><code> * You're free to add application-wide styles to this file and they'll appear at the bottom of the
   * compiled file so the styles you add here take precedence over styles defined in any styles
   * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
   * file per style scope.
   *
   *= require sweetalert2
   *= require bootstrap_and_overrides
   *= require_self
   *= require_tree .
   */
   
  </code></pre>
  <p>I did  rake assets:precompile
  and
  RAILS_ENV=production bin/rails assets:precompile</p>
  <p>There is no error even in the console -- its just not working
  Thanks in advance !</p>