pilgrim 0.1.3 → 0.1.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.
- data/README.rdoc +1 -1
- data/app/views/pilgrim/tags/_dropdown_aux.html.erb +1 -1
- data/lib/pilgrim/load_methods.rb +19 -5
- data/lib/pilgrim/version.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -26,7 +26,7 @@ Choose countries, states and cities via Ajax
|
|
26
26
|
|
27
27
|
|
28
28
|
=== Controller Methods
|
29
|
-
<tt>get_locations</tt> gets the countries, the states of the first selected country, and the cities of the first state inside of 3 collections: @countries, @states, @cities
|
29
|
+
<tt>get_locations(country_id = 0, state_id = 0, city_id = 0)</tt> gets the countries, the states of the first selected country, and the cities of the first state inside of 3 collections: @countries, @states, @cities. The parameters are for pre-select the options in the dropdowns.
|
30
30
|
---
|
31
31
|
|
32
32
|
|
@@ -1 +1 @@
|
|
1
|
-
<%= select form_name, name, options_for_select(data.collect{ |c| [c.name, c.id] },
|
1
|
+
<%= select form_name, name, options_for_select(data[:data].collect{ |c| [c.name, c.id] }, data[:selected]), {}, :data => {:kind => kind, :block => block, :formname => form_name, :name => name}, :class => html_class, :id => html_id %>
|
data/lib/pilgrim/load_methods.rb
CHANGED
@@ -6,7 +6,8 @@ module Pilgrim
|
|
6
6
|
|
7
7
|
module InstanceMethods
|
8
8
|
def get_countries
|
9
|
-
Pilgrim::Country.get_countries
|
9
|
+
countries = Pilgrim::Country.get_countries
|
10
|
+
return countries
|
10
11
|
end
|
11
12
|
|
12
13
|
def get_states(country_id)
|
@@ -19,11 +20,24 @@ module Pilgrim
|
|
19
20
|
state.cities
|
20
21
|
end
|
21
22
|
|
22
|
-
def get_locations
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def get_locations(country_id = 0, state_id = 0, city_id = 0)
|
24
|
+
countries = get_countries
|
25
|
+
|
26
|
+
country_id = countries.first.id if country_id == 0
|
27
|
+
@countries = transform_result(countries, country_id)
|
28
|
+
states = get_states(country_id)
|
29
|
+
|
30
|
+
state_id = states.first.id if state_id == 0 and !states.empty?
|
31
|
+
@states = transform_result(states, state_id)
|
32
|
+
cities = get_cities(state_id)
|
33
|
+
|
34
|
+
city_id = cities.first.id if city_id == 0 and !cities.empty?
|
35
|
+
@cities = transform_result(cities, city_id)
|
26
36
|
end
|
37
|
+
|
38
|
+
def transform_result(data, selected)
|
39
|
+
{data: data, selected: selected}
|
40
|
+
end
|
27
41
|
end
|
28
42
|
|
29
43
|
end
|
data/lib/pilgrim/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pilgrim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|