dawarich/app/helpers/user_helper.rb

19 lines
422 B
Ruby
Raw Normal View History

2025-08-13 14:25:48 -04:00
# frozen_string_literal: true
module UserHelper
2025-09-18 12:29:46 -04:00
def api_key_qr_code(user, size: 6)
2025-08-30 15:32:25 -04:00
json = { 'server_url' => root_url, 'api_key' => user.api_key }
qrcode = RQRCode::QRCode.new(json.to_json)
2025-08-13 14:25:48 -04:00
svg = qrcode.as_svg(
2025-08-30 15:32:25 -04:00
color: '000',
fill: 'fff',
shape_rendering: 'crispEdges',
2025-09-18 12:29:46 -04:00
module_size: size,
2025-08-13 14:25:48 -04:00
standalone: true,
use_path: true,
offset: 5
)
svg.html_safe
end
end