问题描述
我做了很多研究来完成这项工作。但没有解决我的问题 link_to_add_association 在heroku 中不起作用 宝石“茧”
<%= 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(" Your First Name"),id: "someId"%>
</div><br>
<div class="field">
<%= f.label :last_name,"Last Name (required)"%>
<%= f.text_field :last_name,placeholder: raw(" Your Last Name"),id: "someId"%>
</div><br>
<div class="field">
<%= f.label :phone,"Phone (required)"%>
<%= f.text_field :phone,placeholder: raw(" phone"),id: "phoneNumber"%>
</div><br>
<div class="field">
<%= f.label :address,"Address (required)"%>
<%= f.text_field :address,placeholder: raw(" 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",placeholder: raw(" 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",placeholder: raw(" Add a Password")%>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation,placeholder: raw(" 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>
在_address_fields.html.erb
<div class="nested-fields">
<div class="field">
<%= f.label :name,"Address"%>
<%= f.text_field :name,id:"searchTextField",placeholder: raw(" Address")%>
<input id="address" name="address" value='' type="hidden" placeholder="">
<%= f.label :phone,"Phone"%>
<%= f.text_field :phone,id:"phoneNumber",id: "phoneNumber"%>
<%= link_to_remove_association "Remove address",f %><br>
</div>
</div>
在 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 .
在生产.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
在 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 .
*/
我确实耙过资产:预编译 和 RAILS_ENV=生产 bin/rails 资产:预编译
即使在控制台中也没有错误——它只是不工作 提前致谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)