0

I'm consuming a REST endpoint using ActiveResource which has Keys called among others ENV.OM_PRODUCER, ENV.UMS_PRODUCER.

These appear to be causing an issue with my view, I'm getting errors such as:

NameError in AppsController#index

wrong constant name ENV.UMSProducer

There is nothing else in the logs to help me, any suggestions.

Update: I was far from clear earlier.

I am not doing anything with the data yet, in my controller I have:

@apps = App.all

and in the view I have:

<%= @apps.inspect %>

It seems like ActiveResource is interpreting those ENV. keys and its causing an issue. It feels like I need them to be escaped but I don't know how.

snick
  • 15
  • 5
  • Isn't ENV a hash? have you tried ENV["UMSProducer"] ? – Eric C Jan 02 '13 at 22:21
  • What has Keys? The ActiveResource? Like @EricC mentions, `ENV` is a hash (and a special one at that). What does your App (which I assume is the ActiveResource) look like? Are you requiring any other libraries that might be messing things up a bit? – theIV Jan 02 '13 at 23:16
  • The remote API response has those keys. So far this is the only model in the app, there really isn't anything else going on at this point other than me attempting to consume the response and display it. Given what you have both commented on would suggest that the ENV.UMS_PRODUCER key in the remote response could conflict with the local ENV hash. So is there a way to avoid consuming those keys or to escape them so there is no comparison to the local ENV hash? – snick Jan 03 '13 at 01:38

1 Answers1

0

Thanks to this post I determined it was due to the full stop in the key rather than the key name. Putting the code suggested in the post into a .rb file in initializers fixed the problem.

snick
  • 15
  • 5
  • link is broken, but you can look on github issue for the code: https://github.com/rails/activeresource/issues/33#issuecomment-7287916 – Lluís Aug 17 '15 at 12:29