Colin Law wrote in post #983650:
> On 24 February 2011 14:25, Vadim Antropov <[email protected]> wrote:
>> --------------------------
>> NoMethodError in Devise/registrations#new
>>
>> Showing
>> C:/projects/djob/app/views/devise/registrations/_locations.html.erb
>> where line #2 raised:
>>
>> undefined method `map' for :id:Symbol
>> Extracted source (around line #2):
>>
>> 1: <p><%= label_tag :location %><br />
>> 2: <%= collection_select (:location_id, locations, :id,
>
> You are still using the syntax for f.collection_select, but are just
> using collection_select. Check the docs for that method, you need an
> extra parameter before :location_id. See
>
http://ap.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000455
>
> Colin
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
----------------
<p><%= f.label :country %><br />
<%= f.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>
------------------
<%= collection_select(nil, :location_id, locations, :id, :location_name,
{},
{:prompt => "Select an Location"},
{:onchange => "#{remote_function(:url => {:action
=> "update_cities"},
:with =>
"'location_id='+value")}"}) %>
--------------------
NoMethodError in Devise/registrations#new
Showing
C:/projects/djob/app/views/devise/registrations/_locations.html.erb
where line #1 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map
--
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.