0

我正在尝试以数据库的形式选择一个国家及其地区。我有一个表单出现在视图的 sessions#new 操作中,但位于access_requests/_form.html.slim. 它发布到 access_requests#create。在表单中,我subregion_select在视图/会话文件夹中有一个部分。一切正常,除非我发布表单时收到以下错误消息:

Missing partial access_requests/_subregion_select

access_requests/_form.html.slim

= simple_form_for object, url: access_requests_path do |f|
  .form-group
    = f.input :first_name, input_html: { class: "form-control" }
  ...
  = f.simple_fields_for :extra_attributes do |extra_fields|
  .form-group
    = extra_fields.input :country, as: :select, collection: site_countries, prompt: 'Please select a country', label: "Franchisee Billing Country", input_html: { class: "form-control" }
    .form-group
    = label_tag "Franchisee Billing State/Province"
    = render partial: "subregion_select"

_subregion_select.html.slim

#states_provinces_wrapper
  - country_code ||= params[:country_code]
  - country = Carmen::Country.coded(country_code)

  - if country.nil?
    em Please select a country above
  - else
    = select "access_request_form[extra_attributes]", "province", states_provinces_for_select(country_code), class: "form-control"

应用程序.js

$(document).ready(function(){
  $('#access_request_form_extra_attributes_country').change(function(event) {
    var country_code, select_wrapper, url;
    select_wrapper = $('#states_provinces_wrapper');
    $('select', select_wrapper).attr('disabled', true);
    country_code = $(this).val();
    url = "/subregion_options?country_code=" + country_code;
    select_wrapper.load(url);
  });
});

session_controller.rb

def subregion_options
  render partial: "subregion_select"
end
4

1 回答 1

1

改用部分的完整路径(相对于应用程序/视图):

render partial: "sessions/subregion_select"
于 2016-02-02T18:07:45.290 回答