gem cocoon work locally but not in production

125 Views Asked by At

I did alot of research to make this work. but nothing solved mine link_to_add_association not working in heroku gem "cocoon"

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
  <%= render "devise/shared/error_messages", resource: resource %>
    <div class="field">
    <%= f.label :first_name ,"First Name (required)"%>
    <%= f.text_field :first_name, autofocus: true , :size=>"50", required: "true",class: "textbox",placeholder: raw("&#xf007; Your First Name"),id: "someId"%>
  </div><br>
  <div class="field">
    <%= f.label :last_name ,"Last Name (required)"%>
    <%= f.text_field :last_name , :size=>"50", required: "true",class: "textbox",placeholder: raw("&#xf007; Your Last Name"),id: "someId"%>
  </div><br>

  <div class="field">
    <%= f.label :phone ,"Phone (required)"%>
    <%= f.text_field :phone , :size=>"50", required: "true",class: "textbox",placeholder: raw("&#xf095; phone"),id: "phoneNumber"%>
  </div><br>
  <div class="field">
    <%= f.label :address ,"Address (required)"%>
    <%= f.text_field :address , :size=>"50", required: "true",class: "textbox",placeholder: raw("&#xf041; Address"),id: "searchTextField"%>
  </div><br>

  
 

  <div class="field"><br>

     <p class="address"> <%= link_to_add_association "Add more Addresses and Phone numbers", f,:addresses, partial: 'address_fields' %></p>
    </div> 
      <div class="field">
    <%= f.label :image ,"Add Profile Picture"%> <%= f.file_field :image %>
   
 </div>
  <div class="field">
    <%= f.label :email %>
    <%= f.email_field :email, autocomplete: "email" ,class: "textbox",placeholder: raw("&#xf0e0; Your email")%>
  </div>

  <div class="field">
    <%= f.label :password %>
    <% if @minimum_password_length %>
    <em>(<%= @minimum_password_length %> characters minimum)</em>
    <% end %><br />
    <%= f.password_field :password, autocomplete: "new-password" ,class: "textbox",placeholder: raw("&#xf023 Add a Password")%>
  </div>

  <div class="field">
    <%= f.label :password_confirmation %><br />
    <%= f.password_field :password_confirmation, autocomplete: "new-password" ,class: "textbox",placeholder: raw("&#xf023 Password Confirmation")%>
  </div>

  <div class="actions">
    <%= f.submit "Sign up" %>
  </div>
<% end %>

<%= render "devise/shared/links" %>

</div></div></div>

<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.62/jquery.inputmask.bundle.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA-ATN59uXNYOqQoVajiXKhhN2vsSc9Xb0&libraries=places">
</script>
<!-- You forgot closing this -->
       <!-- You forgot starting the below script tag -->
       <script>
       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);
       </script>

</script>

in _address_fields.html.erb

<div class="nested-fields">
  <div class="field">
    <%= f.label :name ,"Address"%>
    <%= f.text_field :name , :size=>"50",class: "textbox" ,id:"searchTextField" ,placeholder: raw("&#xf041; Address")%>
    <input id="address" name="address" value='' type="hidden" placeholder="">
    <%= f.label :phone ,"Phone"%>
    <%= f.text_field :phone , :size=>"50",class: "textbox" ,id:"phoneNumber" ,placeholder: raw("&#xf095; phone"),id: "phoneNumber"%>
    
    <%= link_to_remove_association "Remove address", f %><br>
  </div>
</div>

in application.js

// 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 .

in production.rb

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

in application.css.scss

 * 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 .
 */
 

I did rake assets:precompile and RAILS_ENV=production bin/rails assets:precompile

There is no error even in the console -- its just not working Thanks in advance !

0

There are 0 best solutions below