Skip to content

Commit

Permalink
fix(uuid): Fix uuid method
Browse files Browse the repository at this point in the history
  • Loading branch information
thooams committed Oct 21, 2024
1 parent 2487b32 commit 023d78f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/ui_bibz/concerns/models/searchable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ostruct'

module UiBibz::Concerns::Models::Searchable
extend ActiveSupport::Concern

Expand Down
10 changes: 7 additions & 3 deletions lib/ui_bibz/ui/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ def i18n_set?(key)

# Add "id" in url to match with current record
def inject_url(url, record)
url.gsub(%r{(/id/?)}, "/#{record.id}/").gsub(%r{(/uuid/?)}, "/#{record.uuid}/")
if defined?(record.uuid)
url.gsub(%r{(/uuid/?)}, "/#{record.uuid}/")
else
url.gsub(%r{(/id/?)}, "/#{record.id}/")
end
end

def generate_id(name = nil)
"#{name || 'id'}-#{Random.rand(99_999)}"
def generate_id(name = 'id')
"#{name}-#{Random.rand(99_999)}"
end
end
end

0 comments on commit 023d78f

Please sign in to comment.