Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 2 commits into from

5 participants

@jigfox

No description provided.

@cerdiogenes

+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

:+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

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

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

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

@jim
Owner
jim commented

Closed in favor of #41.

@jim jim closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/carmen/rails/action_view/form_helper.rb
View
4 lib/carmen/rails/action_view/form_helper.rb
@@ -24,7 +24,7 @@ module FormOptionsHelper
# Returns an `html_safe` string containing the HTML for a select element.
def subregion_select(object, method, parent_region_or_code, options={}, html_options={})
parent_region = determine_parent(parent_region_or_code)
- tag = instance_tag(object, method, self, options.delete(:object))
+ tag = instance_tag(object, method, self, options)
tag.to_region_select_tag(parent_region, options, html_options)
end
@@ -62,7 +62,7 @@ def country_select(object, method, *args)
html_options ||= {}
- tag = instance_tag(object, method, self, options.delete(:object))
+ tag = instance_tag(object, method, self, options)
tag.to_region_select_tag(Carmen::World.instance, options, html_options)
end
Something went wrong with that request. Please try again.