I have a multi-page form which creates/edits an event (model held in session) and it''s invites. When the event is edited I want the user to be able to modify the invites without saving. For example: invite = Invite.new "test-J0of1frlU80@public.gmane.org event.invites << invite Right now this automatically adds that invite to the database. How can I keep it from doing this until I call "event.save"? I was thinking about doing a clever validation hook, until I considered deleting invites: event.invites.delete(invite) That will delete from the database before calling "event.save()", which means the user cannot cancel this action by canceling the flow. Currently I''m saving the event object in the session. The user should be able to modify the invitations list all they want without it being final until they finish the flow. Any ideas? So far the only thing I can think of is either keeping the invite associations separate and baking them into the event at the end or creating a new event "clone" at the beginging and merge at the end. Neither of these seem like a graceful solution. Thanks, Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t know for sure if its changed in 2.x However, in 1.1.6 I believe that if you do it the other way around such as ============================invite.event = event ===========================it won''t save automatically. Why do you need to prevent the save? Could your users not just edit the invite anyway? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> ============================> invite.event = event > ===========================> it won''t save automatically.You''re right, this way it wont save the invite, however, it also wont update the event invite list either. (i.e. "event.invites") This is for a 3 page flow where invite management is on the first page. The user should be able to modify the invite list and if they cancel out of the flow (or close their browser), it should not update the database. This is why I don''t want anything to save anything until the last page of the flow. It would be really helpful if the event invite list were to update (without saving) as the user make changes. This way I can show the current list as they tweak it. Thanks for the suggestions - Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Semantic argument: ROA States: HTTP is stateless, so too should your application be. Laymen explanation: Don''t use the session lest you have to. Helpful alternative: Store the state of the resource (not the same as application state). Allow the save. Include a created_at field. If invitation is not sent within X days destroy the invitation. Ever Helpful Alternative( not advised but what the hell ): Store the invitations in a separate array (not through the association and associate them on completion of the form -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This works when the user creates the event, but what about when they try to modify it. If the event is saved every step of the flow, the user wont be able to cancel out of it. Generally users expect everything in a flow to be temporary until they click "Finish" on the last page. I hate storing the event in session, but don''t know of a better way to support a multi-page flow in both create and edit modes. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---