Кто-нибудь использовал omniauth с rails 2.3.8?

Я новичок в Rails, и я пытаюсь использовать omniauth с рельсами 2.3.8. я не смог найти никакого руководства для этой версии рельсов, поэтому я сослался на http://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth .

Я добавил инициализатор следующим образом:

omniauth.rb

OmniAuth::Strategies::Twitter = { 
    :consumer_key => 'xxxxxx', 
    :consumer_secret => 'xxxxxx' 
} 

После этого шага если я попытаюсь перейти по URL-адресу '/ auth / twitter', я получу «Нет Нет доступных экземпляров типа CustomHashCodeExample. Должен квалифицировать распределение с помощью ...

Я работаю над примером проблемы переопределения метода hashCode и equals, но получаю сообщение об ошибке: « Нет доступного включающего экземпляра типа CustomHashCodeExample. Должен квалифицировать выделение с помощью включающий экземпляр типа CustomHashCodeExample (например, xnew A (), где x - это экземпляр CustomHashCodeExample). " Я написал внутренний класс HashPerson и получаю эту ошибку, когда пытаюсь создать экземпляр этого внутреннего класса в другом методе под названием testHashCodeOverride ().

public static void testHashCodeOverride(){   
    System.out.println("\nTest HashCode Override Method");
    System.out.println("==================================\n");

    HashPerson william = new HashPerson("willy");
    HashPerson bill = new HashPerson("willy");          
}

Этот код работает нормально, хотя я не вижу статического внутреннего класса или экземпляра внешнего класса , запутался: (

public class HashCodeExample {

    public static void testHashCodeOverride() {

        HashPerson william = new HashPerson("Willy");
        HashPerson bill = new HashPerson("Willy");
        System.out.println("Hash code for william  = " + william.hashCode());
        System.out.println("Hash code for bill     = " + bill.hashCode());

        HashMap table = new HashMap();
        table.put(william, "Silly");

        if (table.containsKey(william)) {
            System.out.println(table.get(william));
        } else {
            System.out.println("Key " + william + " not found");
        }

        if (table.containsKey(bill)) {
            System.out.println(table.get(bill));
        } else {
            System.out.println("Key " + bill + " not found");
        }


    }

    class HashPerson {
        private static final int HASH_PRIME = 1000003;

        public HashPerson(String name) {
            this.name = name;
        }

        public String toString() {
            return name;
        }

        public boolean equals(Object rhs) {
            if (this == rhs)
                return true;

            // make sure they are the same class
            if (rhs == null || rhs.getClass() != getClass())
                return false;

            // ok, they are the same class. Cast rhs to HashPerson
            HashPerson other = (HashPerson) rhs;

            // our test for equality simply checks the name field
            if (!name.equals(other.name)) {
                return false;
            }

            // if we get this far, they are equal
            return true;
        }
        public int hashCode() {
            int result = 0;
            result = HASH_PRIME * result + name.hashCode();
            return result;
        }
        private String name;

    }
}

45
задан shankshera 20 October 2016 в 03:41
поделиться