views:

215

answers:

2

Hello, I want to add a admin functionality to my webapp with Rails version 3. I want something very simple, there will be only one admin, this funcionality doesn't need a username field, just a password field. I don't know how to do it, can you help me?

Thanks!

+2  A: 

Have a look at 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

As simple as that!

Skilldrick
Thanks, pretty easy, but still it is not very much what a want. How can I add a form, I don't wanna use the bultin browser box. Any ideias?
rodrigo3n
+1  A: 

You can use scaffolding for generating form code and controller code.

http://guides.rubyonrails.org/getting_started.html#getting-up-and-running-quickly-with-scaffolding

and here is a simular question: http://stackoverflow.com/questions/107674/backend-administration-in-rails

hth

funkycottleti