pilgrim 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +55 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/javascripts/pilgrim/application.js +43 -0
  6. data/app/assets/javascripts/pilgrim/tags.js +2 -0
  7. data/app/assets/stylesheets/pilgrim/application.css +13 -0
  8. data/app/assets/stylesheets/pilgrim/tags.css +4 -0
  9. data/app/controllers/pilgrim/application_controller.rb +5 -0
  10. data/app/controllers/pilgrim/tags_controller.rb +31 -0
  11. data/app/helpers/pilgrim/application_helper.rb +64 -0
  12. data/app/models/pilgrim/city.rb +6 -0
  13. data/app/models/pilgrim/country.rb +10 -0
  14. data/app/models/pilgrim/state.rb +7 -0
  15. data/app/views/layouts/pilgrim/application.html.erb +14 -0
  16. data/app/views/pilgrim/tags/_container.html.erb +5 -0
  17. data/app/views/pilgrim/tags/_dropdown.html.erb +3 -0
  18. data/app/views/pilgrim/tags/_dropdown_aux.html.erb +1 -0
  19. data/app/views/pilgrim/tags/change_location.js.erb +6 -0
  20. data/config/routes.rb +5 -0
  21. data/db/migrate/20130430152412_create_pilgrim_countries.rb +12 -0
  22. data/db/migrate/20130430152543_create_pilgrim_states.rb +11 -0
  23. data/db/migrate/20130430152605_create_pilgrim_cities.rb +11 -0
  24. data/db/seeds.rb +0 -0
  25. data/lib/generators/pilgrim/generate_views/generate_views_generator.rb +12 -0
  26. data/lib/generators/pilgrim/install/install_generator.rb +18 -0
  27. data/lib/generators/pilgrim/install/templates/cities.sql +1 -0
  28. data/lib/generators/pilgrim/install/templates/countries.sql +1 -0
  29. data/lib/generators/pilgrim/install/templates/states.sql +1 -0
  30. data/lib/pilgrim.rb +5 -0
  31. data/lib/pilgrim/engine.rb +15 -0
  32. data/lib/pilgrim/load_methods.rb +30 -0
  33. data/lib/pilgrim/version.rb +3 -0
  34. data/lib/tasks/pilgrim_tasks.rake +4 -0
  35. data/test/dummy/README.rdoc +261 -0
  36. data/test/dummy/Rakefile +7 -0
  37. data/test/dummy/app/assets/javascripts/application.js +16 -0
  38. data/test/dummy/app/assets/javascripts/welcome.js +2 -0
  39. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  40. data/test/dummy/app/assets/stylesheets/welcome.css +4 -0
  41. data/test/dummy/app/controllers/application_controller.rb +3 -0
  42. data/test/dummy/app/controllers/welcome_controller.rb +7 -0
  43. data/test/dummy/app/helpers/application_helper.rb +2 -0
  44. data/test/dummy/app/helpers/welcome_helper.rb +2 -0
  45. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  46. data/test/dummy/app/views/pilgrim/tags/_container.html.erb +5 -0
  47. data/test/dummy/app/views/pilgrim/tags/_dropdown.html.erb +3 -0
  48. data/test/dummy/app/views/pilgrim/tags/_dropdown_aux.html.erb +1 -0
  49. data/test/dummy/app/views/pilgrim/tags/change_location.js.erb +6 -0
  50. data/test/dummy/app/views/welcome/index.html.erb +28 -0
  51. data/test/dummy/config.ru +4 -0
  52. data/test/dummy/config/application.rb +59 -0
  53. data/test/dummy/config/boot.rb +10 -0
  54. data/test/dummy/config/database.yml +39 -0
  55. data/test/dummy/config/environment.rb +5 -0
  56. data/test/dummy/config/environments/development.rb +37 -0
  57. data/test/dummy/config/environments/production.rb +67 -0
  58. data/test/dummy/config/environments/test.rb +37 -0
  59. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/test/dummy/config/initializers/inflections.rb +15 -0
  61. data/test/dummy/config/initializers/mime_types.rb +5 -0
  62. data/test/dummy/config/initializers/secret_token.rb +7 -0
  63. data/test/dummy/config/initializers/session_store.rb +8 -0
  64. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/test/dummy/config/locales/en.yml +5 -0
  66. data/test/dummy/config/routes.rb +7 -0
  67. data/test/dummy/db/cities.sql +1 -0
  68. data/test/dummy/db/countries.sql +1 -0
  69. data/test/dummy/db/migrate/20130430204534_create_pilgrim_countries.pilgrim.rb +13 -0
  70. data/test/dummy/db/migrate/20130430204535_create_pilgrim_states.pilgrim.rb +12 -0
  71. data/test/dummy/db/migrate/20130430204536_create_pilgrim_cities.pilgrim.rb +12 -0
  72. data/test/dummy/db/schema.rb +43 -0
  73. data/test/dummy/db/states.sql +1 -0
  74. data/test/dummy/log/development.log +6746 -0
  75. data/test/dummy/public/404.html +26 -0
  76. data/test/dummy/public/422.html +26 -0
  77. data/test/dummy/public/500.html +25 -0
  78. data/test/dummy/public/favicon.ico +0 -0
  79. data/test/dummy/script/rails +6 -0
  80. data/test/dummy/test/functional/welcome_controller_test.rb +9 -0
  81. data/test/dummy/test/unit/helpers/welcome_helper_test.rb +4 -0
  82. data/test/dummy/tmp/cache/assets/C7B/190/sprockets%2F37b103f4623089af1456b90830fe941c +0 -0
  83. data/test/dummy/tmp/cache/assets/C8D/BB0/sprockets%2F60470391328e64dff6727d8e25d56b08 +0 -0
  84. data/test/dummy/tmp/cache/assets/CA9/7E0/sprockets%2F9b7d82455f97a58f93289f436e870e46 +0 -0
  85. data/test/dummy/tmp/cache/assets/CB4/B90/sprockets%2F6d683f8e69169e82c92b5659ff791958 +0 -0
  86. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  87. data/test/dummy/tmp/cache/assets/CEC/730/sprockets%2Fb6120fa65b7a893a79f4795dd53d1097 +0 -0
  88. data/test/dummy/tmp/cache/assets/D13/C60/sprockets%2F2dedb8177c20286c4259c1d58c5646cc +0 -0
  89. data/test/dummy/tmp/cache/assets/D21/5D0/sprockets%2Fe2c4f946939f2d7d0b42d86383755cae +0 -0
  90. data/test/dummy/tmp/cache/assets/D29/710/sprockets%2F38cdb0a6058ad42fbb6ab3217451253f +0 -0
  91. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  92. data/test/dummy/tmp/cache/assets/D3E/F40/sprockets%2F25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
  93. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  94. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  95. data/test/dummy/tmp/cache/assets/D9C/720/sprockets%2F8338047be7bd0efb4fd25a2182eefe15 +0 -0
  96. data/test/dummy/tmp/cache/assets/DC2/A50/sprockets%2F0a4fe302b3dccdcd199083ce04ee9e14 +0 -0
  97. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  98. data/test/dummy/tmp/cache/assets/DF4/470/sprockets%2Fc6b4d923deaf3ab7848cdc4b03ea170e +0 -0
  99. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  100. data/test/fixtures/pilgrim/cities.yml +9 -0
  101. data/test/fixtures/pilgrim/countries.yml +13 -0
  102. data/test/fixtures/pilgrim/states.yml +9 -0
  103. data/test/functional/pilgrim/tags_controller_test.rb +9 -0
  104. data/test/integration/navigation_test.rb +10 -0
  105. data/test/pilgrim_test.rb +7 -0
  106. data/test/test_helper.rb +15 -0
  107. data/test/unit/helpers/pilgrim/tags_helper_test.rb +6 -0
  108. data/test/unit/pilgrim/city_test.rb +9 -0
  109. data/test/unit/pilgrim/country_test.rb +9 -0
  110. data/test/unit/pilgrim/state_test.rb +9 -0
  111. metadata +256 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODIwYzQ2MDdhMTcwZGIwNzlhOTRjZTg4NzBkZGQ4MDQ1OTRjNzc1ZA==
5
+ data.tar.gz: !binary |-
6
+ NWE2NmQwNzQ2MDBkM2M5MDk3Mzg1YTU4MWQyODUzNTllZWFkZDg1Yw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODVmYTk3MzY1YzU2MWFjNWJhOGU5N2JjOGIwYzIzYTgzYWY5ZTQzMjIyYmQz
10
+ MDhiNjE2MTQyZTk5MzlmMDZlNGZhYzE2YTE2M2UyMWQ5YmEwMzUwYTEzMDBj
11
+ Yjg3ZGZhZWNhYmZiYzIwMTZlMGRkOGZlZmVlNGUzYmZhNTdiY2Y=
12
+ data.tar.gz: !binary |-
13
+ NTk4MzFjN2M2ZDc4NTgyYjIyN2ZlNWUxYjM1YTlkMjcwOWM2YjhlY2JjYzY2
14
+ MjQ3NmVlNjlhZjQzNGI0MjdiOWVhYzBlODFjOWI3OThhMDkxMmFkNDgyYjQ2
15
+ OThiYmIyMTM0MTU5NDcwZTJhNzM1YTUxNjIxMjdmODllMjI1ODU=
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,55 @@
1
+ = Pilgrim
2
+ ----
3
+
4
+ Choose countries, states and cities via Ajax
5
+
6
+
7
+ === Installation
8
+
9
+ 1. Add to your gemfile: <tt>gem 'pilgrim'</tt>
10
+ 2. Run <tt>bundle</tt>
11
+ 3. Execute: <tt>rails generate pilgrim:install</tt>
12
+ 4. Run migrations: <tt>rake db:migrate</tt>
13
+ 5. Run seeds: <tt>rake db:seed</tt>
14
+ 6. Add to your routes.rb: <tt>mount Pilgrim::Engine => "/pilgrim", :as => "pilgrim"</tt>
15
+ 7. Generate the views so you can configure them executing: <tt>rails generate pilgrim:generate_views</tt> (this will save the views in your_project/app/views/pilgrim)
16
+ 8. Add to your application.js: <tt>//= require pilgrim/application</tt>
17
+ 9. Watch the test/dummy for an example (watch the welcome controller and its views)
18
+ ---
19
+
20
+
21
+ === Use
22
+
23
+ 1. Add in the action where you will need to load the countries for the view: <tt>get_locations</tt>
24
+ 2. Add in your view inside of a form: <tt><%= select_location_tag :data %></tt> where "data" is the name of the form
25
+ ---
26
+
27
+
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
30
+ ---
31
+
32
+
33
+ === Helper Methods
34
+ <tt>select_location_tag(form_name, params = {})</tt> display the dropdowns for the locations. This is an example of a hash for params:
35
+
36
+
37
+ ...
38
+ params = {
39
+ block: "main",
40
+ country: {
41
+ name: "country_field_name",
42
+ html_class: "some_class"
43
+ },
44
+ state: {
45
+ name: "state_field_name",
46
+ html_class: "some_class"
47
+ },
48
+ city: {
49
+ name: "city_field_name",
50
+ html_class: "some_class"
51
+ }
52
+ }
53
+ ...
54
+
55
+ Where <tt>block</tt> defines an id, so you can use the helper as many times you want changing the value in this key; the configurations for country, state and city are separated and in each one you can define the field name and the class you want to use for each element.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Pilgrim'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,43 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
16
+
17
+ $(document).ready(function(){
18
+ $(".locations_container").on("change", ".dropdown_location", function(e){
19
+ var block = $(this).attr("data-block");
20
+ var kind = $(this).attr("data-kind");
21
+ var city_id = block + "_city";
22
+ var data = {
23
+ value: $(this).val(),
24
+ kind: kind,
25
+ block: block,
26
+ city_name: $("#" + city_id).attr("data-name"),
27
+ city_html_class: $("#" + city_id).attr("class"),
28
+ form_name: $(this).attr("data-formname")
29
+ }
30
+
31
+ if(kind == "country"){
32
+ var state_id = block + "_state";
33
+ data['state_name'] = $("#" + state_id).attr("data-name");
34
+ data['state_html_class'] = $("#" + state_id).attr("class");
35
+ }
36
+
37
+ $.ajax({
38
+ type: "POST",
39
+ url: "/pilgrim/change_location",
40
+ data: data
41
+ });
42
+ });
43
+ });
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,5 @@
1
+ module Pilgrim
2
+ class ApplicationController < ActionController::Base
3
+
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ require_dependency "pilgrim/application_controller"
2
+
3
+ module Pilgrim
4
+ class TagsController < ApplicationController
5
+
6
+ def change_location
7
+ @block = params[:block]
8
+ @kind = params[:kind]
9
+ @form_name = params[:form_name]
10
+ @city_name = params[:city_name]
11
+ @city_html_class = params[:city_html_class]
12
+ value = params[:value]
13
+
14
+ @states = nil
15
+ @cities = nil
16
+
17
+ if @kind == "country"
18
+ @state_name = params[:state_name]
19
+ @state_html_class = params[:state_html_class]
20
+
21
+ country = Pilgrim::Country.find(value)
22
+ @states = country.states
23
+ @cities = @states.first.cities rescue []
24
+ elsif @kind == "state"
25
+ state = Pilgrim::State.find(value)
26
+ @cities = state.cities
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,64 @@
1
+ module Pilgrim
2
+ module ApplicationHelper
3
+
4
+ def select_location_tag(form_name, params = {})
5
+ block = params[:block].nil? ? "main" : params[:block]
6
+ render :partial => "pilgrim/tags/container", :locals => { form_name: form_name, params: params, block: block }
7
+ end
8
+
9
+ def select_for_country(form_name, block, params = {})
10
+ country_name = params[:country][:name] rescue "country_id"
11
+ country_html_class = params[:country][:html_class] + " dropdown_location" rescue "dropdown_location"
12
+ country_html_id = block + "_country"
13
+
14
+ render :partial => "pilgrim/tags/dropdown",
15
+ :locals => {
16
+ form_name: form_name,
17
+ name: country_name,
18
+ selected_position: 1,
19
+ kind: "country",
20
+ block: block,
21
+ html_class: country_html_class,
22
+ html_id: country_html_id,
23
+ data: @countries
24
+ }
25
+ end
26
+
27
+ def select_for_state(form_name, block, params = {})
28
+ state_name = params[:state][:name] rescue "state_id"
29
+ state_html_class = params[:state][:html_class] + " dropdown_location" rescue "dropdown_location"
30
+ state_html_id = block + "_state"
31
+
32
+ render :partial => "pilgrim/tags/dropdown", :locals => { form_name: form_name,
33
+ name: state_name,
34
+ selected_position: 1,
35
+ kind: "state",
36
+ block: block,
37
+ html_class: state_html_class,
38
+ html_id: state_html_id,
39
+ data: @states
40
+ }
41
+ end
42
+
43
+ def select_for_city(form_name, block, params = {})
44
+ city_name = params[:city][:name] rescue "city_id"
45
+ city_html_class = params[:city][:html_class] rescue ""
46
+ city_html_id = block + "_city"
47
+
48
+ render :partial => "pilgrim/tags/dropdown", :locals => { form_name: form_name,
49
+ name: city_name,
50
+ selected_position: 1,
51
+ kind: "city",
52
+ block: block,
53
+ html_class: city_html_class,
54
+ html_id: city_html_id,
55
+ data: @cities
56
+ }
57
+ end
58
+
59
+ def select_for_element_aux(form_name, name, data, selected_position, kind, block, html_class, html_id)
60
+ render :partial => "pilgrim/tags/dropdown_aux", :locals => { form_name: form_name, name: name, data: data, selected_position: selected_position, :kind => kind, :block => block, :html_class => html_class, :html_id => html_id }
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,6 @@
1
+ module Pilgrim
2
+ class City < ActiveRecord::Base
3
+ belongs_to :state
4
+ attr_accessible :name, :state_id
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ module Pilgrim
2
+ class Country < ActiveRecord::Base
3
+ has_many :states
4
+ attr_accessible :code, :continent, :name, :region
5
+
6
+ def self.get_countries
7
+ order("id ASC")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Pilgrim
2
+ class State < ActiveRecord::Base
3
+ belongs_to :country
4
+ has_many :cities
5
+ attr_accessible :name, :country_id
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Pilgrim</title>
5
+ <%= stylesheet_link_tag "pilgrim/application", :media => "all" %>
6
+ <%= javascript_include_tag "pilgrim/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,5 @@
1
+ <div class="locations_container">
2
+ <%= select_for_country form_name, block, params %>
3
+ <%= select_for_state form_name, block, params %>
4
+ <%= select_for_city form_name, block, params %>
5
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="<%= "container_#{block}_#{kind}" %>">
2
+ <%= select_for_element_aux(form_name, name, data, selected_position, kind, block, html_class, html_id) %>
3
+ </div>
@@ -0,0 +1 @@
1
+ <%= select form_name, name, options_for_select(data.collect{ |c| [c.name, c.id] }, 1), {}, :data => {:kind => kind, :block => block, :formname => form_name, :name => name}, :class => html_class, :id => html_id %>
@@ -0,0 +1,6 @@
1
+ <% if @kind == "country" %>
2
+ $('#container_<%= @block %>_state').html('<%=j select_for_element_aux(@form_name, @state_name, @states, 0, "state", @block, @state_html_class, @block + "_state") %>');
3
+ $('#container_<%= @block %>_city').html('<%=j select_for_element_aux(@form_name, @city_name, @cities, 0, "city", @block, @city_html_class, @block + "_city") %>');
4
+ <% elsif @kind == "state" %>
5
+ $('#container_<%= @block %>_city').html('<%=j select_for_element_aux(@form_name, @city_name, @cities, 0, "city", @block, @city_html_class, @block + "_city") %>');
6
+ <% end %>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Pilgrim::Engine.routes.draw do
2
+
3
+ post 'change_location' => 'tags#change_location'
4
+
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePilgrimCountries < ActiveRecord::Migration
2
+ def change
3
+ create_table :pilgrim_countries do |t|
4
+ t.string :code
5
+ t.string :name
6
+ t.string :continent
7
+ t.string :region
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePilgrimStates < ActiveRecord::Migration
2
+ def change
3
+ create_table :pilgrim_states do |t|
4
+ t.references :country
5
+ t.string :name
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :pilgrim_states, :country_id
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePilgrimCities < ActiveRecord::Migration
2
+ def change
3
+ create_table :pilgrim_cities do |t|
4
+ t.references :state
5
+ t.string :name
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :pilgrim_cities, :state_id
10
+ end
11
+ end
data/db/seeds.rb ADDED
File without changes
@@ -0,0 +1,12 @@
1
+ module Pilgrim
2
+ module Generators
3
+ class GenerateViewsGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path("../../../../../app/views", __FILE__)
5
+ desc "Generate Views of Pilgrim"
6
+
7
+ def copy_views
8
+ directory "pilgrim", "app/views/pilgrim"
9
+ end
10
+ end
11
+ end
12
+ end