Reputation: 11799
I'm trying to load an environment variable in my .railsrc
file,
I have defined my RAIL_UTILS_HOME
env var in my .bash_profile like
export RAIL_UTILS_HOME='/Path/to/Rails/utils'
This is what I'm trying to do in .railsrc
to load a default rails template
-T -m $RAIL_UTILS_HOME/template.irb
However my $RAIL_UTILS_HOME
var is not being expanded,
Any idea of how to do this correctly ?
Upvotes: 4
Views: 1200
Reputation: 18845
you should be able to access environment variables via ENV["RAIL_UTILS_HOME"]
regardles of where you do it, so it must also work in a .railsrc
file.
since there is no explicit pattern for a .railsrc
file, i assume that you have something like this in your .irbrc
file:
railsrc_path = File.expand_path('~/.railsrc')
if ( ENV['RAILS_ENV'] || defined? Rails ) && File.exist?( railsrc_path )
begin
load railsrc_path
rescue Exception
warn "Could not load: #{ railsrc_path }" # because of $!.message
end
end
this will load ~/.railsrc
file when you start up your rails console.
Upvotes: 1