Hello, i need help.
Devise + custom action in DeviseRegistrationController + dynamic select.
Manual:
http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails/
Error:
NoMethodError in Devise/registrations#new
Showing C:/projects/djob/app/views/devise/registrations/new.html.erb
where line #37 raised:
undefined method `map’ for Symbol
Extracted source (around line #37):
34:
35:
<%= f.label :country %>
36: <%= collection_select (:country_id, Country.all, :id, :country_name,
{:prompt => “Select a Country”},
37: {:onchange => “#{remote_function(:url =>
{:action => “update_locations”}, :with => “‘country_id=’+value”)}”})
%>
38:
39:
40:
@locations %>
new.html.rb
<%= collection_select (:country_id, Country.all, :id, :country_name,
{:prompt => “Select a Country”},
{:onchange => “#{remote_function(:url => {:action
=> “update_locations”}, :with => “‘country_id=’+value”)}”}) %>
registration_controller.rb
def index
@countries = Country.find(:all)
@locations = Location.find(:all)
@cities = City.find(:all)
end
def update_locations
# Обновляем области и города на основе выбранной страны
country = Country.find(params[:country_id])
locations = country.locations
cities = country.cities
render :update do |page|
page.replace_html 'locations', :partial => 'locations', :object =>
locations
page.replace_html ‘cities’, :partial => ‘cities’, :object =>
cities
end
end
def update_cities
# Обновляем города на основе выбранной области
location = Location.find(params[:location_id])
cities = location.cities
render :update do |page|
page.replace_html 'cities', :partial => 'cities', :object =>