Okay, so really, the Preview action is just like a regular Show  
action, except it has a few more options.

If a post is valid, the user will be redirected to the preview. The  
preview will show how the post looks, and has two buttons: "Publish  
this post" and "Keep editing".

Clicking "Publish this post" will set a flag on the record indicating  
the post is valid and published. (You could use a boolean field  
called :published for this. 0 = unpublished, 1= published.) You could  
then redirect the user back to the main index for editing posts with  
a success message like "Your post has been published".

Clicking "Keep editing" will take the user to the Edit action (not  
the New/Create action), where they can continue editing. When the  
Edit action saves a post, it should redirect back to the Preview  
action as long as the published? flag is not set.

This is a good way to accomplish your goals without using overly  
hacky methods. :)

-- Patrick


On Jul 15, 2008, at 11:14 am, liquid_rails wrote:

> Hi Patrick,
>
> I would prefer to have the preview on a separate page, so that if the
> object is validated, the user is sent to the preview page, and it it
> is not, the user is sent back to the form by using "render :action =>
> 'new'", which will display the form + errors.  On the preview page,
> there would be a choice to continue and agree to terms and conditions
> or to edit the post.  The easiest way I see to do this is to actually
> create the post, and then if the user does not press continue or agree
> to the terms and conditions, delete the posting from the database.
> However, this would require a lot of unnecessary calls to the database
> (if there is a way to store and pass a temporary object), and would
> also cause posting id numbers to not be consecutive (say, if a user
> does not commit to the post.)  I'm tempted to go with this approach
> because it is the easiest, however the inefficiency of this approach
> scares me.
>
> Cheri
>

--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to