Authentication and Login/Logout not working.

Resolved.
Got most of the authentication working but then it seemed to break and no matter what I did, trying to access my login or logout pages gave the errors below, which threw me off because the URL shows (for example), login, the controller (admins) do exist and the action does exists within it. Finally adding lines to routes.rb file fixed it. Good lesson in routes. Also good to note that changes to routes really do require web server restarts, even in development, so it's easy to be caught out by that when trying to get authentication working :bandit:
so:
route redos really require restarts
route redos really require restarts
route redos really require restarts
if you read that you'll remember to do it;

Errors were:

http://localhost:3000/admins/logout
Unknown action
No action responded to show. Actions: index, login, and logout

or

http://localhost:3000/admins/login
Unknown action
No action responded to show. Actions: index, login, and logout

or browser would give server error redirecting page

and/or server would try and serve up page 5-10 times before failing (showed in terminal window that was running web serer, e.g. webrick).

Fix for routes (note: controller called admins not admin) was to add these 2 lines):
map.login 'login', :controller => 'admins', :action => 'login'
map.login 'logout', :controller => 'admins', :action => 'logout'

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s