Rails 3中的简单管理功能

时间:2010-09-05 18:36:31

标签: ruby-on-rails ruby ruby-on-rails-3 admin

我想使用Rails版本3为我的webapp添加管理功能。我想要一些非常简单的东西,只有一个管理员,这个功能不需要用户名字段,只需要一个密码字段。我不知道怎么做,你能帮助我吗?

谢谢!

2 个答案:

答案 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