Rails environment variables failing to load in model -


i have environment variable i'm using in 2 places, 1 in rake task, other in model method. when call rake task, fine , variable loads, when call model doesn't find anything. it's not nil error or other error, returns empty string.

is there reason environment variables overridden or inaccessible model?

it's being used build url:

http://#{appenv['env_var_1']}/this/is/#{appenv['env_var_2']}/a/path 

--one more thing, myabe it's relevant, model method called after_create

edit:

thanks responses, question isn't how access or use env vars, can see i'm using them above. question why not loading in model.

edit 2:

i have 4 relevant appenv variables, , [this weird bear me] when check them on running rake task (puts 4 of them log), expected. when run exact same class method, called after_create in model, 3 of variables empty, , 1 of them holds value of different variable. is:

appenvvar1 empty

appenvvar2 has value of appenvvar4

appenvvar3 empty

appenvvar4 empty

if change method self.method (allowing me run console), , run it, works. i'm pretty sure i've narrowed down issue appenv during after filter. ideas on dig?

rails sets global constant hash env should available anywhere in app after it's initialized, including in models. should able refer enviroment variable (assuming relevant env variables has been set):

"http://#{env['root_domain']}/this/is/#{env['secondary_domain']}/a/path" 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -