diff --git a/.env.sample b/.env.sample
index a89e7d0..fcfec4f 100644
--- a/.env.sample
+++ b/.env.sample
@@ -14,8 +14,8 @@ LOG_ACTION_VIEW=false
# with default value, type gets inferred from
INTEGER=a
-STRING=456
-BOOLEAN=false
+STRING=457
+BOOLEAN=false
# with no default value (evaluated to nil), type must be defined expressively otherwise it reverts to a string type
# INTEGER=:integer
diff --git a/.vscode/settings.json b/.vscode/settings.json
index fbd3c86..a649fba 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -41,5 +41,6 @@
"terminal.background": "#1f1f1f"
},
"workbench.colorTheme": "Default Dark Modern",
+ "inlineFold.unfoldOnLineSelect": true,
// ---------------------------------------------------------
}
\ No newline at end of file
diff --git a/app/controllers/hot_controller.rb b/app/controllers/hot_controller.rb
new file mode 100644
index 0000000..7bc59d1
--- /dev/null
+++ b/app/controllers/hot_controller.rb
@@ -0,0 +1,7 @@
+class HotController < ApplicationController
+ def index
+ logger.info('callee')
+ logger.info(__callee__)
+ logger.info(__method__)
+ end
+end
diff --git a/app/controllers/strong_controller.rb b/app/controllers/strong_controller.rb
new file mode 100644
index 0000000..36d7682
--- /dev/null
+++ b/app/controllers/strong_controller.rb
@@ -0,0 +1,17 @@
+class StrongController < ApplicationController
+ def index
+ logger.info(Hot::Constants)
+ end
+
+ def update
+ logger.info 'parameters', strong_params
+ redirect_to strong_path, notice: 'form is ok'
+ end
+
+ private
+
+ def strong_params
+ # params.require(:strong).permit [:name, :surname, { birth: {} }] # implicit: any fields inside bith
+ params.require(:strong).permit [:name, :surname, { birth: %i[date location] }] # explicit
+ end
+end
diff --git a/app/views/hot/index.html.erb b/app/views/hot/index.html.erb
new file mode 100644
index 0000000..633d56b
--- /dev/null
+++ b/app/views/hot/index.html.erb
@@ -0,0 +1,4 @@
+
+
Hot#index
+ <%= Hot::Live %>
+
diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb
index 078efad..2bf4bd3 100644
--- a/app/views/layouts/_navbar.html.erb
+++ b/app/views/layouts/_navbar.html.erb
@@ -5,6 +5,8 @@
<% end %>
+ <%= link_to 'Strong', strong_path, class: :menu %>
+ <%= link_to 'Hot', hot_path, class: :menu %>
<%= link_to 'Flash', flash_path, class: :menu %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 037af26..a6b8af3 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -14,7 +14,7 @@
<%= tag :meta, name: :viewport, content: 'width=device-width,initial-scale=1' %>
<% if Rails.env.development? %>
<%= tag :meta, name: 'turbo-prefetch', content: false %>
- <%= tag :meta, name: 'stimulus-debug', content: HotConstants.stimulus_debug %>
+ <%= tag :meta, name: 'stimulus-debug', content: Hot::Constants.stimulus_debug %>
<% end%>
diff --git a/app/views/strong/index.html.erb b/app/views/strong/index.html.erb
new file mode 100644
index 0000000..b7f3fda
--- /dev/null
+++ b/app/views/strong/index.html.erb
@@ -0,0 +1,34 @@
+
+
Form with strong parameters
+ <%= form_with url: update_strong_path, class:"bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4" do |form| %>
+
+
+ <%= form.label :name, "Name:", class:"block text-gray-700 text-sm font-bold mb-2" %>
+
+
+ <%= form.text_field 'strong[name]', class:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+
+
+
+ <%= form.label :surname, "Surname:", class:"block text-gray-700 text-sm font-bold mb-2" %>
+
+
+ <%= form.text_field 'strong[surname]', class:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+
+
+
+
+ <%= form.label :birth_date, "Birth Date:", class:"block text-gray-700 text-sm font-bold mb-2" %>
+ <%= form.text_field 'strong[birth][date]', class:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+
+
+ <%= form.label :birth_location, "Birth Location:", class:"block text-gray-700 text-sm font-bold mb-2" %>
+ <%= form.text_field 'strong[birth][location]', class:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+
+
+
+
+ <%= form.submit class:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" %>
+
+ <% end %>
+
diff --git a/config/application.rb b/config/application.rb
index a5cde27..f122478 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -15,7 +15,9 @@ module EasyGoingRails
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
- config.autoload_lib(ignore: %w[assets tasks formatters hot_constants monkey_patches])
+ # config.autoload_lib(ignore: %w[assets tasks formatters hot_constants monkey_patches])
+ # config.autoload_lib(ignore: %w[assets tasks formatters monkey_patches])
+ config.autoload_lib(ignore: %w[assets tasks])
# main application title defined from current module name, see module above
config.application_title = module_parent.to_s.titleize
diff --git a/config/initializers/hot_changes.rb b/config/initializers/hot_changes.rb
index 046ed6d..e04966b 100644
--- a/config/initializers/hot_changes.rb
+++ b/config/initializers/hot_changes.rb
@@ -1,6 +1,6 @@
return unless defined?(Rails::Server)
-require Rails.root.join('lib', 'hot_constants', 'hot_constants')
-
-HotConstants.on_change(:log_active_record) { |bool| ActiveRecord::Base.logger.level = bool ? :debug : :fatal }
-HotConstants.on_change(:log_action_view) { |bool| ActionView::Base.logger.level = bool ? :debug : :fatal }
+Rails.application.config.after_initialize do
+ Hot::Constants.on_change(:log_active_record) { |bool| ActiveRecord::Base.logger.level = bool ? :debug : :fatal }
+ Hot::Constants.on_change(:log_action_view) { |bool| ActionView::Base.logger.level = bool ? :debug : :fatal }
+end
diff --git a/config/initializers/rails_live_reload.rb b/config/initializers/rails_live_reload.rb
index 570df71..bd45792 100644
--- a/config/initializers/rails_live_reload.rb
+++ b/config/initializers/rails_live_reload.rb
@@ -5,7 +5,7 @@ if defined?(RailsLiveReload) && Rails.env.development?
# HOT Constants
config.watch(%r{/\.env$}, reload: :always)
config.watch(%r{/\.env\.sample$})
- config.watch(%r{/config/initializers/hot_changes.rb$})
+ # config.watch(%r{/config/initializers/hot_changes.rb$})
# USEFUL for tailwind changes!!!!
config.watch %r{app/assets/builds/tailwind.css}, reload: :always
diff --git a/config/initializers/strong_parameters.rb b/config/initializers/strong_parameters.rb
new file mode 100644
index 0000000..cec22c3
--- /dev/null
+++ b/config/initializers/strong_parameters.rb
@@ -0,0 +1,3 @@
+Rails.application.configure do
+ config.action_controller.action_on_unpermitted_parameters = :raise
+end
diff --git a/config/routes.rb b/config/routes.rb
index 8387cd5..36f1068 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,6 @@
Rails.application.routes.draw do
+ get 'strong/index'
+ get 'hot/index'
resources :scores
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
@@ -15,4 +17,8 @@ Rails.application.routes.draw do
get 'flash/redirect_with_both' => 'flash#redirect_with_both', as: :flash_redirect_with_both
get 'flash/from_render' => 'flash#from_render', as: :flash_from_render
post 'flash/from_turbo' => 'flash#from_turbo', as: :flash_from_turbo
+
+ get 'hot' => 'hot#index', as: :hot
+ get 'strong' => 'strong#index', as: :strong
+ post 'strong' => 'strong#update', as: :update_strong
end
diff --git a/lib/hot_constants/hot_constants.rb b/lib/hot/constants.rb
similarity index 94%
rename from lib/hot_constants/hot_constants.rb
rename to lib/hot/constants.rb
index a72e753..142be40 100644
--- a/lib/hot_constants/hot_constants.rb
+++ b/lib/hot/constants.rb
@@ -1,22 +1,23 @@
require 'dotenv'
# Hot Live Constants
-module HotConstants
+module Hot::Constants
HOTENV = {} # rubocop:disable Style/MutableConstant
LISTENERS = {} # rubocop:disable Style/MutableConstant
LOGGER = SemanticLogger[self]
+ TOTO = 'titi'
class << self
def initialize
@old_definitions = {}
@hot_definitions = {}
- set_definitions
+ load_definitions
load_values
end
- def set_definitions
- LOGGER.info('--set_definitions')
+ def load_definitions
+ LOGGER.debug('--load_definitions3')
new_definitions = Dotenv.parse('.env.sample')
@@ -40,7 +41,7 @@ module HotConstants
end
def load_values
- LOGGER.info('--load_values')
+ LOGGER.debug('--load_values')
new_env = Dotenv.parse
constants_to_delete = HOTENV.except(*new_env.keys)
diff --git a/lib/hot/live.rb b/lib/hot/live.rb
new file mode 100644
index 0000000..8029317
--- /dev/null
+++ b/lib/hot/live.rb
@@ -0,0 +1,8 @@
+module Hot
+ # Hot Live constants
+ class Live
+ def initialize
+ puts 'initialized'
+ end
+ end
+end
diff --git a/lib/monkey_patches/rails_live_reload/watcher.rb b/lib/monkey_patches/rails_live_reload/watcher.rb
index ac9b038..b1038fd 100644
--- a/lib/monkey_patches/rails_live_reload/watcher.rb
+++ b/lib/monkey_patches/rails_live_reload/watcher.rb
@@ -15,7 +15,7 @@ module RailsLiveReload
private
def before_reload(files)
- perform_when_change(files, ENV_SAMPLE_FILE) { HotConstants.set_definitions }
+ perform_when_change(files, ENV_SAMPLE_FILE) { HotConstants.load_definitions }
perform_when_change(files, ENV_FILE) { HotConstants.load_values }
perform_when_change(files, INITIALIZER) { load Rails.root.join('config', 'initializers', 'hot_changes.rb') }
end