carmen-ruby / carmen-rails

NOT ACTIVELY MAINTAINED Rails adapter for Carmen (provides country_select and subregion_select)
MIT License
215 stars 159 forks source link

carmen rails #35

Open reiranke opened 11 years ago

reiranke commented 11 years ago

hi i got this error NoMethodError at /signup undefined method `downcase' for nil:NilClass

<% parent_region ||= params[:parent_region] %> this---> <% country = Carmen::Country.coded(parent_region) %> ``` <% if country.nil? %> Please select a country above <% elsif country.subregions? %> <%= subregion_select(:order, :state_code, parent_region) %> ```
desmondcain commented 11 years ago

I had to alter this block a bit by adding a conditional to handle nil parent_regions

<% unless parent_region.nil? %>
  <% country = Carmen::Country.coded(parent_region) %>  
<% end %>

This worked for me but I'm not sure if this is the best workaround so I'm open to corrections by anyone more knowledgeable on this specific issue.

mmastoras commented 10 years ago

What worked for me was to create the country_code and state_code migration with :default => "" as Carmen::Country.coded will handle being passed a "" but not a nil.

frandroid commented 10 years ago

Oh, that's excellent!

robvelor commented 10 years ago

@mmastoras Thanks! That worked for me too. I hope rails 4 support comes soon!