Skip to content

Commit 542a8b9

Browse files
committed
feat: add user_id to logs
1 parent c74edfd commit 542a8b9

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

rails-bootstrap/app/controllers/application_controller.rb

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def after_sign_in_path_for(resource)
3737

3838
private
3939

40+
def append_info_to_payload(payload)
41+
super
42+
payload[:user_id] = signed_in? ? current_user.id : "guest"
43+
end
44+
4045
def user_not_authorized
4146
flash[:alert] = t("security.access_denied")
4247
redirect_to root_path

rails-bootstrap/config/deploy.rb

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
run_locally do
9393
## Set your env accordingly.
94+
execute "RAILS_ENV=#{fetch(:stage)} bundle exec rails assets:precompile"
9495
execute "RAILS_ENV=#{fetch(:stage)} bundle exec rails webpacker:clobber"
9596
execute "RAILS_ENV=#{fetch(:stage)} bundle exec rails webpacker:compile"
9697
execute "rsync -av --delete ./public/assets/ #{fetch(:deploy_user)}@#{rsync_host}:#{shared_path}/public/assets/"

rails-tailwind/app/controllers/application_controller.rb

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def after_sign_in_path_for(resource)
3737

3838
private
3939

40+
def append_info_to_payload(payload)
41+
super
42+
payload[:user_id] = signed_in? ? current_user.id : "guest"
43+
end
44+
4045
def user_not_authorized
4146
flash[:alert] = t("security.access_denied")
4247
redirect_to root_path

rails-tailwind/config/deploy.rb

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
run_locally do
9393
## Set your env accordingly.
94+
execute "RAILS_ENV=#{fetch(:stage)} bundle exec rails assets:precompile"
9495
execute "RAILS_ENV=#{fetch(:stage)} bundle exec rails webpacker:clobber"
9596
execute "RAILS_ENV=#{fetch(:stage)} bundle exec rails webpacker:compile"
9697
execute "rsync -av --delete ./public/assets/ #{fetch(:deploy_user)}@#{rsync_host}:#{shared_path}/public/assets/"

0 commit comments

Comments
 (0)