Question: *Yes, this question has been asked before. 2 years ago. I felt bad about bumping it up, and figured it'd be a better idea to start a new thread.*

Much like the other question's OP, I have generated my Rails app correctly, changed my databases.yml to use MySQL, and still it is trying to use SQLite3. When I run a rake db: command, it works without errors. It generates the tables in the database, but in the browser, the applications keeps giving errors suggesting it is trying to access (/create) a sqlite database.

Has anyone yet found an answer to this issue? My databases.yml:

```
development:
  adapter: mysql2
  host: localhost
  database: robinkanters_dev
  username: [[ correct username ]]
  password: [[ correct password ]]

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  host: localhost
  database: robinkanters_test
  username: [[ correct username ]]
  password: [[ correct password ]]

production:
  adapter: mysql2
  host: localhost
  database: robinkanters_prod
  username: [[ correct username ]]
  password: [[ correct password ]]

```

Robin Kanters

*PS. This is my first time posting on SO, please go easy on me*

EDIT: I figured I didn't really explain the problem.

Answer: 
I have made the assumption that you probably want to translate each digit to itself as well as all the normal letter mappings, plus mapping `0` to `+`. So I made this dictionary to handle the mappings:

```
var map = new Dictionary<char, string>()
{
    { '0', "+0"},
    { '1', "1" },
    { '2', "2ABC"},
    { '3', "3DEF"},
    { '4', "4GHI"},
    { '5', "5JKL"},
    { '6', "6MNO"},
    { '7', "7PQRS"},
    { '8', "8TUV"},
    { '9', "9WXYZ"},
};

```

My permutate function then looks like this:

```
Func<IEnumerable<char>, IEnumerable<IEnumerable<char>>> permutate = null;
permutate = cs =>
{
    var result = Enumerable.Empty<IEnumerable<char>>();
    if (cs.Any())
    {
        result = map[cs.First()].Select(c => new [] { c });
        if (cs.Skip(1).Any())
        {
            result =
                from xs in result
                from ys in permutate(cs.Skip(1))
                select xs.Concat(ys);
        }
    }
    return result;
};

```

That's it.

You can use it like this:

```
var digits = "(08) 8234-5678"
    .Where(x => char.IsDigit(x));

var results =
    permutate(digits)
        .Select(x => new string(x.ToArray()));

```

The result is a list of strings where each string is a permutation of the input number.

If you don't want to map digits to digits, just take them out of the original dictionary definition, but you must keep a single character for the digit `1` for it to work.

Let me know if this works for you.
Here's a non-recursive solution, that

* Given a number, calculates the first word for it
* Given a word, "increments" it to find the next word

```
public static class TelephoneFinder
{
    static char[] firstDigits = new char[]
                   { '0', '1', 'A', 'D', 'G', 'J', 'M', 'P', 'T', 'W' };
    public static string First(string number)
    {
        char[] firstWord = new char[number.Length];
        for (int i = 0; i < number.Length; i++)
        {
            var c = number.Substring(i, 1);
            firstWord[i] = firstDigits[int.Parse(c)];
        }
        return new String(firstWord);
    }

    static Dictionary<char, char> rollovers = new Dictionary<char, char> { 
        { '1', '0' }, { '2', '1' }, { 'D', 'A' }, { 'G', 'D' }, { 'J', 'G' },
        { 'M', 'J' }, { 'P', 'M' }, { 'T', 'P' }, { 'W', 'T' }, { '[', 'W' } };
    public static string Next(string current)
    {
        char[] chars = current.ToCharArray();
        for (int i = chars.Length - 1; i >= 0; i--)
        {
            // Increment current character
            chars[i] = (char)((int)chars[i] + 1);

            if (rollovers.ContainsKey(chars[i]))
                // Roll current character over
                // Will then continue on to next character
                chars[i] = rollovers[chars[i]];
            else
                // Finish loop with current string
                return new String(chars);
        }
        // Rolled everything over - end of list of words
        return null;
    }
}

```

Called as e.g.

```
string word = TelephoneFinder.First("867");
while (!String.IsNullOrEmpty(word))
{
    Console.WriteLine(word);
    word = TelephoneFinder.Next(word);
}

```

It could probably use some tidying up, but it's a general non-recursive solution that can be modified to work for similar "cross product" situations.