DyingToLearn wrote:
> 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.
I found out that FF and IE "disable" the back button for a particular
form if you submit the form to the page that rendered the form itself (I
typed this by hand, it could not work as written here, but the concept
is valid):
$ rails test
$ cd test
$ ruby script/generate controller back
$ cat > app/controllers/back_controller.rb
class BackController < ApplicationController
def backtest
if request.method == :post
session[:state] = 'saved'
redirect_to :action => 'backtest'
end
end
def clear
session[:state] = nil
redirect_to :action => 'backtest'
end
end
^D
$ cat > app/views/back/backtest.html.erb
<html>
<head>
<title>Backtest</title>
</head>
<body>
<% if session[:state] %>
<%= 'Record saved' %>
<% else %>
<% form_tag :action => "backtest" do %>
<input type="submit" value="Submit">
<% end %>
<% end %>
</body>
</html>
^D
Now, if you go to
http://localhost:3000/back/backtest
and hit submit, you get the 'Record saved' message, but the back button
of the browser does not take you back to 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 [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
-~----------~----~----~----~------~----~------~--~---