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 :id:Symbol
Extracted source (around line #37):

34:
35: <p><%= f.label :country %><br />
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")}"})
%></p>
38:
39:
40: <div id="locations"><%= render :partial => 'locations', :object =>
@locations %></div>
------------------------------------------------------------------

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")}"}) %></p>


<div id="locations"><%= render :partial => 'locations', :object =>
@locations %></div>
<div id="cities"><%= render :partial => 'cities',   :object => @cities
%></div>
--------------------------------------------------------------------

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 =>
cities
    end
  end
--------------------------------------------------------------------------

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to