Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## The error page
- NameError in Admin#index
- Showing admin/index.html.haml where line #1 raised:
- uninitialized constant Authentication::USERS
- Extracted source (around line #1):
- 1: - if authenticated?
- 2: = render :controller => 'admin/categories'
- 3: = render :controller => 'admin/users'
- /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:275:in `load_missing_constant'
- /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing'
- lib/authentication.rb:11:in `authenticated?'
- app/views/admin/index.html.haml:1:in `_run_plugin_47app47views47admin47index46html46haml'
- /usr/bin/thin:19:in `load'
- /usr/bin/thin:19
- ## lib/authenticaton.rb
- module Authentication
- def authenticate
- authenticated? || deny_authentication
- end
- def authenticated?
- if !session[:name].nil? and !session[:password].nil?
- user = USERS[session[:name]]
- user['password'] == session[:password] unless user.nil?
- elsif USERS['skip']
- true
- else
- false
- end
- end
- def deny_authentication
- flash[:notice] = "Vous n'êtes pas autorisé à accéder à cette page"
- redirect_to categories_path
- end
- end
- ## config/users.yml
- production:
- test:
- password: test
- test:
- skip: true
- development:
- test:
- password: test
- ## config/initializers/users.rb
- USERS = YAML.load_file("#{RAILS_ROOT}/config/users.yml")[RAILS_ENV]
Add Comment
Please, Sign In to add comment