launchscout / nku

NKU Class Spring
5 stars 14 forks source link

Quick Issue, not sure of syntax for create in StudentsController #38

Closed staffordw1 closed 10 years ago

staffordw1 commented 10 years ago

Here's my code:

screen shot 2014-02-06 at 4 29 45 pm

It seems that no matter what I change these to I can't get it to except the conditions in the if statement, it always takes the else. I've gotten it so that I no longer get any errors of any kind but it still fails no matter what. The documentation that I can find online for rails seems to be more about creating login stuff rather than creating the new users with this password_digest stuff so I keep getting confused using the wrong code in the wrong places...

mitchlloyd commented 10 years ago

You've got a chicken and egg problem here. You're looking up students and authenticating before creating them.

I'm thinking the code that you pasted here is more appropriate for your SesssionsController where you are creating a session for a student that already exists. In the current version of the app, anyone can create a Student (a.k.a "Sign Up"); there is no authentication there.

staffordw1 commented 10 years ago

Ok, so should I use the code I had before?

I changed it back to this because I don't really remember what I had before and I don't really want to mess with git to try to restore my previous commit... :

screen shot 2014-02-06 at 5 06 14 pm

I seem to still have the same problem, the user is getting rejected for some reason, is there something I'm missing in the previous code or is it something else?

staffordw1 commented 10 years ago

I've got this: screen shot 2014-02-06 at 5 33 06 pm

this: screen shot 2014-02-06 at 5 34 16 pm this:

screen shot 2014-02-06 at 5 34 57 pm

and this: screen shot 2014-02-06 at 5 36 24 pm

And I feel like one of those things must be wrong...

mitchlloyd commented 10 years ago

You should throw a debugger after your "else" in your create action. Then you can type "@student.errors" and see why it isn't saving.

Another idea: print out these error messages like we did for posts in the first assignment.

I think you'll find that you're missing a password_confirmation field which is required by has_secure_password by default.

On Thursday, February 6, 2014, staffordw1 notifications@github.com wrote:

I've got this: [image: screen shot 2014-02-06 at 5 33 06 pm]https://f.cloud.github.com/assets/6433255/2104695/b943b05a-8f7e-11e3-9c81-94af3bc2e655.png

this: [image: screen shot 2014-02-06 at 5 34 16 pm]https://f.cloud.github.com/assets/6433255/2104703/dbe86484-8f7e-11e3-82f7-c7ff4b389f2a.png this:

[image: screen shot 2014-02-06 at 5 34 57 pm]https://f.cloud.github.com/assets/6433255/2104708/fb3c7afa-8f7e-11e3-9212-3ee360368def.png

and this: [image: screen shot 2014-02-06 at 5 36 24 pm]https://f.cloud.github.com/assets/6433255/2104718/29610202-8f7f-11e3-9859-cae85cb0d7d3.png

And I feel like one of those things must be wrong...

Reply to this email directly or view it on GitHubhttps://github.com/gaslight/nku/issues/38#issuecomment-34382920 .

staffordw1 commented 10 years ago

Yeah, I just saw that and stuck it in my code, now it looks like I just have the same issue listed here: https://github.com/gaslight/nku/issues/31

It's telling me my passwords are blank. So, I'll start combing through that to fix it. I'll close the issue for now, and reopen if I can't fix it through that. Thanks!