I am trying to select a country and its region in a form to the db. I have a form that appears in sessions#new action of the view but is located in access_requests/_form.html.slim
. It posts to access_requests#create. In the form I have a subregion_select
partial in the views/sessions folder. Everything works fine except when I post the form I get the following error message:
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"
application.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);
});
});
sessions_controller.rb
def subregion_options
render partial: "subregion_select"
end
Use the partial's full path (relative to app/views) instead: