我想使用Rails版本3为我的webapp添加管理功能。我想要一些非常简单的东西,只有一个管理员,这个功能不需要用户名字段,只需要一个密码字段。我不知道怎么做,你能帮助我吗?
谢谢!
答案 0 :(得分:6)
查看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
就这么简单!
答案 1 :(得分:2)
您可以使用scaffolding生成表单代码和控制器代码。
http://guides.rubyonrails.org/getting_started.html#getting-up-and-running-quickly-with-scaffolding
这是一个类似的问题: Backend administration in Ruby on Rails
HTH