views:

178

answers:

4

Hello - hard question:

I have my login-partial in my application.html.erb-layout.

Now I want to validate it, if the user pushes the submit button and show error-messages for it, if e.g. the passwordfield is empty.

But how do I do that? For getting the error messages, I must use

render :action => 'create'

But there I have to know, from which action I came from. Beside different pages, need different seperate instance variables (which arn't reproduced with render :action).

Second try with

redirect_to :back

loses the errors-array...!

How can I solve this problem? Found nothing in the net =(

A: 

So not a direct answer to your question, but I would skip rolling your own login and checkout something like the restful authentication plugin

script/plugin install git://github.com/technoweenie/restful-authentication.git
script/generate authenticated user sessions
rnicholson
A: 

I'm using restful_authentication!

and I'm including the login-partial into my appliation.html.erb layout...?!

Lichtamberg
A: 

Let me see if I get you correctly:

  • You have a login box in your application layout.
  • When you press the submit button you are posting to the create action of your session controller

If that's the case, you can just render the new action of your session controller and render that page as well.

So you can login from everypage, but if anything goes wrong you end up in the session controller new action.

Would that be an option?

Maran
No,thats the behaviour I want to prevent :)
Lichtamberg
A: 

Solved it - used Ajax-Forms!

Lichtamberg