2023-08-08 19:29:01 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-08-08 16:48:09 +00:00
|
|
|
module ApplicationHelper
|
2023-08-08 19:29:01 +00:00
|
|
|
def logged_in?
|
|
|
|
session[:user_id].present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_user
|
|
|
|
@current_user ||= User.find(session[:user_id]) if logged_in?
|
|
|
|
end
|
2023-08-18 20:02:39 +00:00
|
|
|
|
|
|
|
def update_flash
|
|
|
|
turbo_stream.replace "flash_wrapper" do
|
|
|
|
render "shared/flash"
|
|
|
|
end
|
|
|
|
end
|
2023-10-16 07:06:26 +00:00
|
|
|
|
|
|
|
def updated_at(object)
|
|
|
|
return "" if object.created_at == object.updated_at
|
|
|
|
|
|
|
|
object.updated_at.strftime("%Y-%m-%d %H:%M")
|
|
|
|
end
|
2023-08-08 16:48:09 +00:00
|
|
|
end
|