countries_regions_and_cities_by_pete 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c639a777560483526b6171998059f9b979b63804e54af296ec3653ceccc00e9b
4
- data.tar.gz: 5c5e6a07cb146258d5fd86788d63f0b580a97757d397ad2dd4f488e60cab150e
3
+ metadata.gz: a5ee0f04abf7947eeb12e9d439e725a795f46d5bdd0053800132ed5b34e91be6
4
+ data.tar.gz: 53dc92b1c9dc592434428a07c7d796b210631cf8b6a097120726dc9d7d6ad120
5
5
  SHA512:
6
- metadata.gz: d82dc05ac4221be0b7d50712d6607d081b3e49a671fd45cf5fbdda5e90cf27a0aaccb0e1ad89d5e58a9e1989245c35301cfbbc5e560e80dfcc6381486b3c734f
7
- data.tar.gz: ce6f6d77dcd1fce62e01c229daf9d7a0ba5e95c850d3d839a396df52c82f23a9dcbf911aa4d770622af9d21d50829592cdec0e2a99bded03e5cc18598760dd76
6
+ metadata.gz: f972f39f4b79773cb8db40b8129a4756f661bbe7d27b32c3a35780bcff0b349018f5c411b38d922002c5473fb096fc7685c345c8560a5dac44fdbbdf6de295da
7
+ data.tar.gz: 2cf59af52e404bc382e7811a4b6d927f59e55ece4b56483d460705861f196359f7ead03b20f31fd2121496a7f4992d7895df21e9e05d4fe29fab2e742fc33a0b
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
data/README.md CHANGED
@@ -52,8 +52,7 @@ gem 'countries_regions_and_cities_by_pete'
52
52
  bundle install
53
53
  ```
54
54
 
55
- 6. Go to the application directory in Terminal and run the following command to install the necessary files from the gem:
56
-
55
+ 6. Go to the application directory in Terminal and run the following command to install the necessary code and files from the gem:
57
56
 
58
57
  ```ruby
59
58
  bundle exec rake 'install_countries_regions_and_cities_by_pete[Place]'
@@ -66,8 +65,8 @@ bundle exec rake 'install_countries_regions_and_cities_by_pete[Place]'
66
65
  ```
67
66
 
68
67
  8. Paste this code to your _form.html.erb file: /app/views/places/_form.html.erb
69
- ```ruby
70
68
 
69
+ ```ruby
71
70
  <div class="field" id="country_field">
72
71
  <%= render partial: "shared/country_select_by_pete", locals: {model: form.object.class.name, label: "Country", selected: form.object.country} %>
73
72
  </div>
@@ -77,7 +76,6 @@ bundle exec rake 'install_countries_regions_and_cities_by_pete[Place]'
77
76
  <div class="field" id="city_field">
78
77
  <%= render partial: "shared/city_select_by_pete", locals: {model: form.object.class.name, label: "City", selected_region: form.object.region, selected_country: form.object.country, selected: form.object.city} %>
79
78
  </div>
80
-
81
79
  ```
82
80
  9. Allow parameters (country,region and city) in your controller: /app/controllers/places_controller.rb
83
81
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CountriesRegionsAndCitiesByPete
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
@@ -1,10 +1,12 @@
1
1
  require_relative '../peterconsuegra_recipes'
2
+ require 'colorize'
2
3
 
3
4
  #bundle exec rake 'install_countries_regions_and_cities_by_pete[model]'
4
5
 
5
6
  desc 'install countries_regions_and_cities required files'
6
7
  task :install_countries_regions_and_cities_by_pete, [:model] do |t, args|
7
8
 
9
+ #Require all models
8
10
  Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file }
9
11
 
10
12
  #Base routes
@@ -18,22 +20,26 @@ task :install_countries_regions_and_cities_by_pete, [:model] do |t, args|
18
20
  #Adding partials
19
21
  PeterConsuegraRecipes::move_templates(src_folder,"#{rails_app_folder}/app/views/shared/",["_city_select_by_pete.html.erb","_country_select_by_pete.html.erb","_region_select_by_pete.html.erb"])
20
22
 
21
- #Adding concern
23
+ #Adding concern file
22
24
  PeterConsuegraRecipes::move_template(src_folder,"#{rails_app_folder}/app/controllers/concerns/","globalization_by_pete.rb")
23
25
 
24
- #Adding jQuery
26
+ #Adding js asset
25
27
  PeterConsuegraRecipes::move_template(src_folder,"#{rails_app_folder}/public/countries_regions_and_cities_by_pete/","jquery-3.6.0.min.js")
26
28
 
27
- #Adding route to routes.rb
29
+ #Adding route
28
30
  PeterConsuegraRecipes::add_route(hash['base_route'],"get_regions","get")
29
31
  PeterConsuegraRecipes::add_route(hash['base_route'],"get_cities","get")
30
32
 
31
33
  #Adding concern to controller
32
34
  PeterConsuegraRecipes::add_concern_to_controller("include GlobalizationByPete\n",hash['controller_file'],hash['controller_class'])
33
35
 
34
- #Adding migration
36
+ #Adding country, region and city fields
37
+ puts "Running command:".blue
38
+ puts "rails generate migration AddFieldsTo#{hash['model_class']} country:string region:string city:string".green
35
39
  `rails generate migration AddFieldsTo#{hash['model_class']} country:string region:string city:string`
36
40
  sleep 2
41
+ puts "Running command:".blue
42
+ puts "rake db:migrate".green
37
43
  `rake db:migrate`
38
44
 
39
45
  #Print necessary code
@@ -55,7 +61,7 @@ task :install_countries_regions_and_cities_by_pete, [:model] do |t, args|
55
61
  puts ' <div class="field" id="city_field">
56
62
  <%= render partial: "shared/city_select_by_pete", locals: {model: form.object.class.name, label: "City", selected_region: form.object.region, selected_country: form.object.country, selected: form.object.city} %>
57
63
  </div>'.red
58
- puts "Allow countries_regions_and_cities_by_pete globalization params in your controller #{hash['controller_file']}:".red
64
+ puts "Allow :city, region and :country params in your controller #{hash['controller_file']}:".red
59
65
  puts "params.require(:#{hash['model'].downcase}).permit(:city, :region, :country)".red
60
66
 
61
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: countries_regions_and_cities_by_pete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Consuegra