4

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!

rodrigoalvesvieira
  • 7,895
  • 15
  • 63
  • 84

2 Answers2

6

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
  • 69,215
  • 34
  • 177
  • 229
  • 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? – rodrigoalvesvieira Sep 06 '10 at 01:46
2

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: Backend administration in Ruby on Rails

hth

Community
  • 1
  • 1
funkycottleti
  • 298
  • 2
  • 7