It is a difficult problem to deal with, since Tech-savvy users will
press the BACK button when they actually WANT a second record in the
database!

One method I have used is to redirect to the edit page after a create
has been performed. For example

def create
  @object = Object.new
  if @object.save
    redirect_to :action => 'edit'
  eles
    render :action => 'new'
  end
end

then they aren't tempted to press back because they are already at the
edit page.

I hope that helps.

S2 akira wrote:
> Pretty standard stuff:
> 1. User fills out form
> 2. User submits form
> 3. User thinks "doh! an error!"
> 4. User hits the browser back button
> 5. User updates the data in the form
> 6. User *thinks* he is updating the data by hitting submit again, but
> inserts another record.
>
> Now we have two records in the database, one is the correct one, and one
> is the bad one. How do we know witch one is the good one? The second
> one! I hear you all scream. But does that mean we should delete the
> first one? How do you deal with this situation?
> I think it is quite obvious what the user intended to do, and we should,
> in our webapp, do what the user wanted to do, not annoy him with stupid
> error messages like "Sorry, you can't submit the same form twice", or
> "Sorry, a record with this ID already exists in our database"
> Is there a nice solution in rails to this very frequent problem in web
> applications?
>
> Thanks
> --
> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to