Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

rails get environment variable

ENV['foo']
# nil

ENV.fetch('foo')
# Raises KeyError (key not found: "foo")

ENV.fetch('foo', :default_need_not_be_a_string)
# => :default_need_not_be_a_string

ENV['foo'] = '123'
ENV['foo']
# => '123'

ENV.fetch('foo')
# => '123'

ENV.fetch('foo', :default_need_not_be_a_string)
# => '123'


Source by docs.ruby-lang.org #
 
PREVIOUS NEXT
Tagged: #rails #environment #variable
ADD COMMENT
Topic
Name
8+1 =