Module: Redmine::Utils

Defined in:
lib/redmine/utils.rb

Defined Under Namespace

Modules: DateCalculation, Shell

Class Method Summary collapse

Class Method Details

.random_hex(n) ⇒ Object

Generates a n bytes random hex string Example:

random_hex(4) # => "89b8c729"

40
41
42
# File 'lib/redmine/utils.rb', line 40

def random_hex(n)
  SecureRandom.hex(n)
end

.relative_url_rootObject

Returns the relative root url of the application


22
23
24
25
26
# File 'lib/redmine/utils.rb', line 22

def relative_url_root
  ActionController::Base.respond_to?('relative_url_root') ?
    ActionController::Base.relative_url_root.to_s :
    ActionController::Base.config.relative_url_root.to_s
end

.relative_url_root=(arg) ⇒ Object

Sets the relative root url of the application


29
30
31
32
33
34
35
# File 'lib/redmine/utils.rb', line 29

def relative_url_root=(arg)
  if ActionController::Base.respond_to?('relative_url_root=')
    ActionController::Base.relative_url_root=arg
  else
    ActionController::Base.config.relative_url_root = arg
  end
end