baddr 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9fbb53c49bfc330fb8b6163f2abba2f00b10fd2
4
- data.tar.gz: 049018eb8c76e3e9728213597b6301f663435e35
3
+ metadata.gz: 624da24d1ce54ef28e7dd25bd0f4930e0af5c33e
4
+ data.tar.gz: a2d4b71e3152438c7e8fe638104aff83067b2ea1
5
5
  SHA512:
6
- metadata.gz: 1d7afe1a4ad881124416e36ddbc4424d0017d6d91b04aae71616792bd1e1a3da092069bf8c7e76460aa36f2a77069bc0946a7fe2506b776e26a307797ed90c89
7
- data.tar.gz: 10ff51913ff157aa6bb9a468058bd49d948432c01ced93ecfda90bce22004a82ee663faf72843d3dd92cc8cb960380f11d62f62d2b8e8704519d39b54d1eb28a
6
+ metadata.gz: 47c3bd0ab7016984e85be482cb454de81cb131df33361a41de63fdc09f64fe4bd2d5ad498ba972509c6135031601b4fd591ca605b0cf5c8c2b543d9941253ab1
7
+ data.tar.gz: ac5634ce02ce122a60ed7a44dc3ce35a763a6e348420f26ecccdd0949828b8a6b716055569c42a8d185666d526c31427a3811a78f7f165e1e251c32899027f8a
@@ -9,4 +9,5 @@ $ ->
9
9
  citiesSelect.append(optionTag city) for city in response
10
10
  return
11
11
 
12
- $("select.baddr-states").change((e) -> loadCitiesByState this).change()
12
+ select = $("select.baddr-states").change((e) -> loadCitiesByState this)
13
+ select.change() unless $("select.baddr-cities option:selected").size() > 0
@@ -10,7 +10,7 @@ module Baddr
10
10
  def baddr_city_tag(name, value, options={})
11
11
  options[:class] = (options.with_indifferent_access[:class].presence || []) << 'baddr-cities'
12
12
  select_options = if @state_value.present?
13
- options_from_collection_for_select(City.where(state: @state_value), 'id', 'name', value)
13
+ options_from_collection_for_select(City.for_state(@state_value), 'id', 'name', value)
14
14
  else
15
15
  ''
16
16
  end
@@ -1,5 +1,6 @@
1
1
  class City < ActiveRecord::Base
2
- scope :for_state, ->(state) {
3
- where state_id: State.find_by_code(state.upcase).id
2
+ belongs_to :state
3
+ scope :for_state, ->(state) {
4
+ joins(:state).where('states.code' => state.upcase)
4
5
  }
5
6
  end
@@ -1,2 +1,3 @@
1
1
  class State < ActiveRecord::Base
2
+ has_many :cities
2
3
  end
@@ -1,3 +1,3 @@
1
1
  module Baddr
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baddr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Eduardo da Fonseca