我有一个在我的MSSQL数据库中创建数据库用户的当前系统。这些用户可以与我们编写的其他客户端连接到数据库。我需要挑战用户输入已在数据库的SQL Server安全性/登录中定义的用户名和密码。
我能够连接到数据库并使用rails创建表,我无法找到有关如何对我正在连接的数据库进行身份验证的任何信息。
我们的架构中已经有一个包含用户信息的表,例如usr_name,usr_desc,usr_email等。
答案 0 :(得分:0)
假设您没有进行散列,并且您可以使用
在rails中正确设置用户模型 #assuming your table/model is called user your user name field is called user_name and your password field is called password
user = User.find_by_user_name_and_password
if user
#do authenticated stuff
else
#don't do authenticated stuff
end
查看http://guides.rubyonrails.org/active_record_querying.html
向下谈论动态发现者。这些是为rails模型中的每个字段创建的。这就是使sql在rails中查询的原因。