Sorting page flow for has_many in Rails

Posted by Gareth on Stack Overflow See other posts from Stack Overflow or by Gareth
Published on 2009-10-04T19:09:02Z Indexed on 2010/05/09 23:18 UTC
Read the original article Hit count: 154

Filed under:
|

I have a page flow allowing the user to choose an object ("Player") to add to a has_many :players association in another model.

 1 => List existing players for object [Enter player name] 
 2 => List of matching players [Select player] 
 3 => Confirmation page [Press 'Add']
 4 => Done

I want users to be able to choose "New Player" instead of selecting a player at step 2, in which case the user will go through the standard New Player process elsewhere on the site.

However, after that's done, the user should return to step 3 with the new player in place.

I don't know what the best way is to implement this. I don't want to duplicate the player creation code, but I don't want to dirty up the player creation code too much just for this case.

I also don't want to start sticking IDs in the session if I can help it. It's fine in simple cases but if the user ever has two windows/tabs then things start behaving badly.

What do you think?

© Stack Overflow or respective owner

Related posts about restful

Related posts about ruby-on-rails