我想使用 Rails 版本 3 向我的 webapp 添加一个管理功能。我想要一些非常简单的东西,只有一个管理员,这个功能不需要用户名字段,只需要一个密码字段。我不知道该怎么做,你能帮我吗?
谢谢!
最佳答案
看看this Railscast on HTTP simple authentication :
# products_controller.rb
before_filter :authenticate
protected
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "foo" && password == "bar"
end
end
就这么简单!
关于ruby-on-rails - Rails 3 中的简单管理功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3647250/