working database into ActiveRecord