I'm not really sure if there is a single problem here or I have approached this in the wrong way, but any suggestions would be greatly appreciated!
In the application when a user signs up they get privileges and their page gets set up, they can then invite colleagues by email.
The email has an activation code tagged on the end. An example url would be "/user/new/xxxxxxxxx".
Here's the problem: I need the colleague to be able to create a User account as well, with just their basic info, so they can log into the account and set up their corner of the app.
When the colleague makes a mistake on the user sign up form, the url forgets there is an activation code, and jumps back with validation messages and a pretty bare url of '/users'. When the colleague amends their mistakes and clicks sign up, they are submitted as a fully fledged user, not an invited colleague.
This happens because i have an if clause on the 'users/new' page
<% if @activation_code %>
Show colleague messages of invitation and happiness
<% else %>
Show fully fledged user ego stroking messages
<% end %>
My routing to find the code parameter of the url is:
map.signup '/users/new/:code', :controller => 'users', :action => 'new', :code => nil
Like I said before, have I approached this completely wrong? is is there one problem here?
UPDATE This Rails Cast Episode Solved nearly all of the problems I was having: Beta Invitations
Although to distinguish if the person was coming from an invitation or not I just used this conditions block:
if [email protected]_id.blank?
and that worked great.