fact_name => fact_names[name] will always fail
as facts_names[name] is a hash, and you are expecting either a fact_name_id => facts[name] or a fact_name => FactName.find(facts[name]).