views:

21

answers:

2

I'm using rails to build a website.

I have a yaml file contails some colors, which is config/colors.yml

---
- white
- red
- blue
- yellow
- ...

And, there is an erb file app/views/users/setting.html.erb, which will need the data in config/colors.yml, and put them in a tag.

I don't know what's the correct way to read the yaml file. Can I read once and store them in memory, or I should read it each time the page is requested?

+1  A: 
John Topley
@John, thank you! This is just what I want to know
Freewind
+1  A: 

If the colors never change, it's okay to cache them. Follow this DZone tutorial.

3rd result for Google: ruby yaml tutorial.

mcandre
@mcandre, thanks for the tutorial
Freewind