What I have is 2 hash’s one gets dumped from a backend that deals nothing specifically with rails. The other is a manually built hard-coded hash. Kind of like a index of known possibilities.
What I want to do is compare what the backend spits out vs what I have in my hash thats like an index so when I render my view I can have the display look a bit more appealing.
Now I could do something like this with php and an array
array("monkey" => "Monkey", "server" => "server")
and then do a str_replace("monkey", $var, array)
ok thats a poor example but its been a while since I played with php and I am a bit rusty off the top of my head. But thats the notion
the end result is when I find “monkey” in one I want to replace it with “Monkey” for the view’s sake.
edit/revision/addition
Ok realized Im not working with a hash, im actually working with an array or a JSON object..
pretty_service = {"namenode" => "Name Nodes","secondarynamenode" => " Secondary Name Nodes", "datanode" => "Data Nodes", "web" => "Web", "tasktracker" => "Task Trackers", "jobtracker" => "Job Trackers", "oozie" => "Oozie", "single-namenode" => "Single NameNode", "single-databse" => "Single Database" }
What I want to is if my strings I am checking contain any one of the keys I want to replace it with the value. Not sure how exactly to do that with rails styling coding. There is some decent concepts below already but I’ve tried them and they don’t seem to work for me. Knowing this now, is there a differnt approach to working this up?
String.gsub can do that.