countries_regions_and_cities_by_pete 0.3.0 → 0.3.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3a5bac3bbe77bbb0d51b0aca351822c1599c0234eac570866295d64269ac0a
|
4
|
+
data.tar.gz: d2258ed2205a19a7d4362862d73b6f19a5720fb2fe14d31fa7b0af9b037c3caf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a2a69fc36c8175d75a7322730052c2af06cb9f020c7bc3722b1d6580b4d689bd04bddd356a2afa9c375cbe3cdc85667a1f0c3d17ca401af1cc0fe9208d38f86
|
7
|
+
data.tar.gz: 8b3a917f25adab6f4501efa16c6acc786e57ef9299ef54cb62d866bd6386621ba535744a538efdb31563f718cf93278db197803bcbb494bd24d99e88e367ba77
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -40,22 +40,33 @@ bundle exec rake db:create
|
|
40
40
|
bundle exec rails g scaffold Place name:string description:text
|
41
41
|
```
|
42
42
|
|
43
|
-
4.
|
43
|
+
4. Add this line to your application's Gemfile:
|
44
44
|
|
45
|
+
```ruby
|
46
|
+
gem 'countries_regions_and_cities_by_pete'
|
47
|
+
```
|
48
|
+
|
49
|
+
5. Go to your application's directory in Terminal and run:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
bundle install
|
53
|
+
```
|
54
|
+
|
55
|
+
6. Go to the application directory in Terminal and run the following command to install the necessary code and files from the gem:
|
45
56
|
|
46
57
|
```ruby
|
47
58
|
bundle exec rake 'install_countries_regions_and_cities_by_pete[Place]'
|
48
59
|
```
|
49
60
|
|
50
|
-
|
61
|
+
7. Add jQuery to your layout file: /app/views/layouts/application.html.erb
|
51
62
|
|
52
63
|
```html
|
53
64
|
<script src='/countries_regions_and_cities_by_pete/jquery-3.6.0.min.js'></script>
|
54
65
|
```
|
55
66
|
|
56
|
-
|
57
|
-
```ruby
|
67
|
+
8. Paste this code to your _form.html.erb file: /app/views/places/_form.html.erb
|
58
68
|
|
69
|
+
```ruby
|
59
70
|
<div class="field" id="country_field">
|
60
71
|
<%= render partial: "shared/country_select_by_pete", locals: {model: form.object.class.name, label: "Country", selected: form.object.country} %>
|
61
72
|
</div>
|
@@ -65,9 +76,8 @@ bundle exec rake 'install_countries_regions_and_cities_by_pete[Place]'
|
|
65
76
|
<div class="field" id="city_field">
|
66
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} %>
|
67
78
|
</div>
|
68
|
-
|
69
79
|
```
|
70
|
-
|
80
|
+
9. Allow parameters (country,region and city) in your controller: /app/controllers/places_controller.rb
|
71
81
|
|
72
82
|
```ruby
|
73
83
|
def place_params
|
Binary file
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require_relative '../peterconsuegra_recipes'
|
2
|
-
require '
|
3
|
-
require "tty-file"
|
2
|
+
require 'colorize'
|
4
3
|
|
5
|
-
#bundle exec rake 'install_countries_regions_and_cities_by_pete[
|
6
|
-
|
7
|
-
Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file }
|
4
|
+
#bundle exec rake 'install_countries_regions_and_cities_by_pete[model]'
|
8
5
|
|
9
6
|
desc 'install countries_regions_and_cities required files'
|
10
7
|
task :install_countries_regions_and_cities_by_pete, [:model] do |t, args|
|
11
|
-
|
8
|
+
|
9
|
+
#Require all models
|
10
|
+
Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file }
|
11
|
+
|
12
12
|
#Base routes
|
13
13
|
rails_app_folder = Dir.pwd
|
14
14
|
gem_folder = File.expand_path('../../../.', __FILE__)
|
@@ -20,22 +20,26 @@ task :install_countries_regions_and_cities_by_pete, [:model] do |t, args|
|
|
20
20
|
#Adding partials
|
21
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"])
|
22
22
|
|
23
|
-
#Adding concern
|
23
|
+
#Adding concern file
|
24
24
|
PeterConsuegraRecipes::move_template(src_folder,"#{rails_app_folder}/app/controllers/concerns/","globalization_by_pete.rb")
|
25
25
|
|
26
|
-
#Adding
|
26
|
+
#Adding js asset
|
27
27
|
PeterConsuegraRecipes::move_template(src_folder,"#{rails_app_folder}/public/countries_regions_and_cities_by_pete/","jquery-3.6.0.min.js")
|
28
28
|
|
29
|
-
#Adding route
|
29
|
+
#Adding route
|
30
30
|
PeterConsuegraRecipes::add_route(hash['base_route'],"get_regions","get")
|
31
31
|
PeterConsuegraRecipes::add_route(hash['base_route'],"get_cities","get")
|
32
32
|
|
33
33
|
#Adding concern to controller
|
34
34
|
PeterConsuegraRecipes::add_concern_to_controller("include GlobalizationByPete\n",hash['controller_file'],hash['controller_class'])
|
35
35
|
|
36
|
-
#Adding
|
37
|
-
|
36
|
+
#Adding country, region and city fields
|
37
|
+
puts "Running command:".blue
|
38
|
+
puts "rails generate migration AddCountriesRegionsAndCitiesByPeteFieldsTo#{hash['model_class']} country:string region:string city:string".green
|
39
|
+
`rails generate migration AddCountriesRegionsAndCitiesByPeteFieldsTo#{hash['model_class']} country:string region:string city:string`
|
38
40
|
sleep 2
|
41
|
+
puts "Running command:".blue
|
42
|
+
puts "rake db:migrate".green
|
39
43
|
`rake db:migrate`
|
40
44
|
|
41
45
|
#Print necessary code
|
@@ -57,7 +61,7 @@ task :install_countries_regions_and_cities_by_pete, [:model] do |t, args|
|
|
57
61
|
puts ' <div class="field" id="city_field">
|
58
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} %>
|
59
63
|
</div>'.red
|
60
|
-
puts "Allow
|
61
|
-
puts "params.require(:#{hash['model']}).permit(:city, :region, :country)".red
|
64
|
+
puts "Allow :city, region and :country params in your controller #{hash['controller_file']}:".red
|
65
|
+
puts "params.require(:#{hash['model'].downcase}).permit(:city, :region, :country)".red
|
62
66
|
|
63
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.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Consuegra
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- bin/console
|
86
86
|
- bin/setup
|
87
|
+
- countries_regions_and_cities_by_pete-0.3.0.gem
|
87
88
|
- countries_regions_and_cities_by_pete.gemspec
|
88
89
|
- countries_regions_and_cities_by_peterconsuegra-0.2.5.gem
|
89
90
|
- lib/countries_regions_and_cities_by_pete.rb
|