Keeping a query-string in devise sign up

Viewed 2138

I am using rails with devise for signing up. Also I added an invite code, so not everybody can sign up.

The invite code gets transmitted via query-string like "/users/sign_up?invite_code=wajdpapojapsd" and gets added to a hidden field of the sign-up form with "f.hidden_field :invite_code, :value => params[:invite_code]".

This works pretty well. The only problem is that if the sign up doesn't get validated and rejected, devise redirects to "/users" and loses the query string with the invite_code in it.

As the email stays in the sign up form after the failed attempt, I believe that this should also work for the invite code. As a worst case solution redirecting :back after a failed sign up and losing the email, but keeping the invite code, would be better than the way it works now.

EDIT: By now I ve set up a registration controller for devise, but don't have any idea how to get the desired behavior.

Any help on how to keep the query string or just the invite code would be awesome.

4 Answers
Related