乐者为王

Do one thing, and do it well.

uninitialized constant Typus::Authentication::ByPassword

使用的Rails版本是2.3.5,所以在安装typus的时候需要加上-r 2-3-stable。

1
script/plugin install git://github.com/fesplugas/typus.git -r 2-3-stable

在安装完后执行script/generate typus出现了下面的错误:

1
uninitialized constant Typus::Authentication::ByPassword

在网上找到的答案是因为和restful_authentication中Authentication模块有冲突,可以将app/models/user.rb中的:

1
2
3
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken

改成

1
2
3
include ::Authentication
include ::Authentication::ByPassword
include ::Authentication::ByCookieToken

再次执行generator时提示:

1
undefined method 'login_regex' for Typus::Authentication:Module

经过再三查找,原来是user.rb文件中还有别的调用Authentication的地方,全部加上::符号,问题解决了。

Comments