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

rails needs hash with the object on key :object #36

Closed jigfox closed 10 years ago

kdiogenes commented 10 years ago

+1

with the actual code, using form_for and this line:

<%= f.country_select :country, { priority: %w(BR), object: f.object } %>

generates a wrong number of arguments (1 for 0) exception.

ghost commented 10 years ago

:+1: Had the exact issue above.

I'm currently using the below in my Gemfile right now to get Carmen-Rails to work in Rails 4.0.1 with SimpleForm.

gem 'carmen-rails', '~> 1.0.0', github: 'jigfox/carmen-rails', branch: 'patch-1' 

Please merge this PR and release a new gem!

robsilva commented 10 years ago

Dan,

Did you get the 'State' filed to automatically populate based on the 'country' field selection? Can you post the relevant code please? (Gemfile, view/partials/JS ?) Thanks in advance!

ghost commented 10 years ago

Sorry @robsilva no I have not. My application is only using US States right now, so I just wrote a helper to do it outside of any JS.

require 'carmen'

module ApplicationHelper
  include Carmen

  def us_states_for_select
    Country.named('United States').subregions.map{|state| [state.name, state.code]}
  end
end
bshelton229 commented 10 years ago

I somehow missed this PR before opening #41. #41 should retain Rails 3 compatibility.

jim commented 10 years ago

Closed in favor of #41.