launchscout / nku

NKU Class Spring
5 stars 14 forks source link

Very simple problem, cant figure out! #41

Closed beisert1 closed 10 years ago

beisert1 commented 10 years ago

I am trying to create a sign in page but I am not sure as to why I am getting this error?! It seems so simple and I have been trying everything for a long time now.

image

Trying rake routes does not show the sign in page but I'm not sure how to proceed and this is preventing me from really doing much else for this assignment.

image

As you can see below, I have created the html sign in page. I defined sign in page in the controller file.

image

image

hopscotchscooter commented 10 years ago

I think if you make a separate "sessions" controller that will handle your sign in/sign out stuff, that will help you tremendously.

beisert1 commented 10 years ago

Thank you I will try that but would it be possible to find a solution with having everything under the same "users" controller? I feel like it will make things more complicated having them in separate controllers.

mitchlloyd commented 10 years ago

Right now your problem is that you don't have any route that matches "/users/signin". The route that will match that URL is "/users/:id" where whatever comes after the slash is interpreted as an ID. That mean that when you hit "/users/signin" id is "signin".

If you want to keep everything in UsersController you'll need to define a custom action in your routes.rb file. "Checkout 2.10.2 Adding Collection Routes" in the Rails routing guide.

The fact that "/users/signin" needs to be a "collection" action even though you're singing in one user is a clue that this is going against the grain of the users controller. You're mixing the concerns of managing user records and managing the current user's session.

To get an idea of what to expect around controller size, I just looked through a large Rails app that some experience programmers worked on. Most controllers were about 35 lines long. The biggest controller in the app is called SessionsController. It's 78 lines long and probably could use some refactoring. Keeping your classes small and plentiful should be a goal.

beisert1 commented 10 years ago

Thanks fixed now! You were right to create a new session controller too :+1: