I find it very helpful if you keep track of your breeding/dragons. For example this is my breeding chart (note: The levels represent what level they were when I recorded the breeding, not when they were first hatched):
1. Crackle Lvl. 4 Fire Dragon+Muir Lvl 4 Earth Dragon= Ural lvl. 5 Lava Dragon
2. Crackle Lvl. 4 Fire Dragon+Damek Lvl. 6 Plant Dragon= ButterCup Lvl. 5 Flower Dragon
3. Damek Lvl. 6 Plant Dragon+Muir Lvl. 4 Earth Dragon= Geo Lvl. 7 Tree Dragon
4. Ural Lvl. 5 Lava Dragon+Damek Lvl. 6 Plant Dragon= Name Lvl. # Lava Dragon (unhatched so it has no level yet)
And this is my list of the dragons that I have:
Name| Level| Type| Elements| Gen|
Geo| 7| Tree| Plant, Earth| 2
Muir| 4| Earth| Earth| 1
Ural| 5| Lava| Fire, Earth| 2
Sol| 4| Fire| Fire| 1
Sear| 4| Fire| Fire| 1
Crackle| 4| Fire| Fire| 1
Damek| 6| Plant| Plant| 1
Ivy| 5| Plant| Plant| 1
Buttercup| #| Flower| Fire, Plant| 2 (In Colosseum at the moment and forgot level)
I think, to breed a rainbow dragon you need two level 10 dragons with all of the elements. Like say you breed a fire+plant dragon and then you get the flower dragon. Then you breed a earth+fire dragon and get the lava dragon. Then you breed the flower with the lava dragon. Now you get a dragon with fire, plant, and earth elements. Then you keep leveling up and breeding dragons until you get two dragon that, when bred together, create an egg with all of the elements (rainbow) Although you would obviously have to keep trying to get the right outcome.
P.S. The sun and moon dragon does not require a rainbow dragon as you can't breed a rainbow with other dragons. Maybe a rainbow+rainbow? But I think that would just give another rainbow :/