jquery在本地运行良好,但在heroku中则不行

jquery在本地运行良好,但在heroku中则不行,jquery,ruby-on-rails,ajax,Jquery,Ruby On Rails,Ajax,在我的rails应用程序表单中,我试图向我的控制器发送一个jquery请求,以便在选择某个字段时更新下拉列表,它在本地工作正常,但在heroku上不工作 我尝试了RAILS\u ENV=production-rake-assets:precompile,但什么也没发生 在我添加另一个名为area的字段之前,它曾经工作过 我的表格 我的路线 我认为这并不是问题的原因,但是表单中有无效的标记-body和form标记。我认为对于Heroku,您需要预编译资产并将其推送到Heroku上。我知道这不是一个

在我的rails应用程序表单中,我试图向我的控制器发送一个jquery请求,以便在选择某个字段时更新下拉列表,它在本地工作正常,但在heroku上不工作

我尝试了
RAILS\u ENV=production-rake-assets:precompile
,但什么也没发生

在我添加另一个名为area的字段之前,它曾经工作过

我的表格

我的路线


我认为这并不是问题的原因,但是表单中有无效的标记-
body
form
标记。我认为对于Heroku,您需要预编译资产并将其推送到Heroku上。我知道这不是一个好主意。我已经这么做了@uzaifIt不是问题的原因,我想,但是您的表单中有无效的标记-
body
form
标记。我认为对于Heroku,您需要预编译资产并将其推送到Heroku上。我知道这不是个好主意。我已经这么做了@uzaif
<head>
  <script src="/assets/mama.js"></script>
</head>
<%= form_with(model: shop, local: true) do |form| %>
<% if shop.errors.any? %>
<div id="error_explanation">
  <h2><%= pluralize(shop.errors.count, "error") %> prohibited this shop from being saved:</h2>
  <ul>
    <% shop.errors.full_messages.each do |message| %>
    <li><%= message %></li>
    <% end %>
  </ul>
</div>
<% end %>
<body>
  <form >
    <h1>Add Your Shop</h1>
    <fieldset>
      <legend><span class="number">1</span>Your basic info</legend>
      <label for="name">Name:</label>
      <%= form.text_field :name, id: :shop_name %>
      <label for="mail">Email:</label>
      <%= form.text_field :email, id: :shop_email %>
      <label for="password">Description:</label>
      <%= form.text_area :description, id: :shop_description %>
      <label>Image:</label>
      <%= form.file_field :imageshop, id: :shop_imageshop %>
    </fieldset>
    <fieldset>
      <legend><span class="number">2</span>Important Infos</legend>
      <label for="bio">Location:</label>
      <%= form.text_field :location, id: :shop_location %>
    </fieldset>
    <fieldset>
      <label for="bio">Registeration Number:</label>
      <%= form.text_field :registeration_number, id: :registeration_number %>
    </fieldset>
    <fieldset>
      <label for="job">Website:</label>
      <%= form.text_field :web, id: :shop_web %>
      <label>Phone Number:</label>
      <%= form.text_field :phone, id: :shop_phone %><br><label class="light" for="business">Business Type</label>
      <%= form.select :busness, ['Service Provider', 'Products Based Business'] %><label class="light" for="design">Business Category</label><br>
      <%= form.select :category, ['Electronics', 'Fashion', 'Furniture', 'Kitchen Stores', 'Restraunts', 'Hotels', 'General Stores', 'Grocery Stores'] %>
      <label>Please select a State:</label>
      <%= form.select :state, options_for_select([["Select a State",""]] + State.all.map { |c| [c.name, c.id] },selected:  shop.state ), {}, id: "state"%>
      <label>Please select a District:</label>
      <%= form.select :city, options_for_select([["Select a District",""]]),{}, :id => 'city' %>
      <label>Please select a Area:</label>
      <%= form.select :area, options_for_select([["Select a Area",""]]),{}, :id => 'area' %>
    </fieldset>
    <div class="bobo" style="text-align:center; padding:0; margin:0;">
      <%= form.submit class: "btn-success" %>
    </div>
  </form>
</body>
</html>
<% end %>
<script type="text/javascript">
var  selectedCity = "";
<% if shop.city.present? %>
  selectedCity = <%= shop.city  %>;
<% end %>
var  selectedArea = "";
<% if shop.area.present? %>
selectedArea = <%= shop.area  %>;
<% end %>
$(function() {
  if ($("select#state").val() == "") {
    $("select#city option").remove();
    var row = "<option value=\"" + "" + "\">" + "city" + "</option>";
    $(row).appendTo("select#city");
   }
   var $val = $("select#state").val();
   if($val != ""){
     getCitiesOfState($val);
   }

   $("select#state").change(function() {
    var id_value_string = $(this).val();
    if (id_value_string == "") {
     $("select#city option").remove();
     var row = "<option value=\"" + "" + "\">" + "city" + "</option>";
     $(row).appendTo("select#city");
    } else {
     // Send the request and update city dropdown
      getCitiesOfState(id_value_string)
    }
   });


  if ($("select#city").val() == "" && selectedCity == "") {
    $("select#area option").remove();
    var row = "<option value=\"" + "" + "\">" + "area" + "</option>";
    $(row).appendTo("select#area");
   }
   var $val2 = $("select#city").val();
   console.log("val________", $val2);
   if($val2 != "" && selectedCity == ""){
    getAreasOfCity($val2)
   }
   console.log("selected_city________", selectedCity);
   if (selectedCity != "") {

    getAreasOfCity(selectedCity)
   }

    $("select#city").change(function() {
      var id_value_string = $(this).val();
      if (id_value_string == "") {
        $("select#area option").remove();
        var row = "<option value=\"" + "" + "\">" + "area" + "</option>";
        $(row).appendTo("select#area");
      } else {
        // Send the request and update city dropdown
        getAreasOfCity(id_value_string)

      }
    });


  });  
</script>
#get cities from state
  def get_cities_by_state
    @cities = State.find(params[:state]).cities
    respond_to do |format|
      format.json { render :json => @cities }
    end
  end 

  #get area from city
  def get_areas_by_city
    @areas = City.find(params[:city]).areas
    respond_to do |format|
      format.json { render :json => @areas }
    end
  end
post :get_cities_by_state,       action: :get_cities_by_state, controller: :products
  post :get_areas_by_city,       action: :get_areas_by_city, controller: :products