Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是这个网站和 ruby on rails 的新手!我有一个常见的 authlogic 安装,如果用户没有设置密码,我希望自动生成用户注册密码。最好的方法是什么?
解决方案是:
#app/models/User.rb class User < ActiveRecord::Base #... before_validation_on_create { |record| record.randomize_password unless record.password } #... end