Forum: Ruby on Rails Best Practices For back/cancel/return button

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John K. (Guest)
on 2006-02-15 01:51
(Received via mailing list)
Are there any best practices for implementing a back/cancel/return
button... even when the page you want to return people too is 2 pages
back (when people submit form and then want to return)?

Thanks :-)

Your Friend,

John K.
http://www.kopanas.com


=====================================================================
http://www.soen.info - source of the freshest software engineering
information on the net
http://cusec.soen.info - software engineering conference
Dylan S. (Guest)
on 2006-02-15 02:07
(Received via mailing list)
Hey John !  I just use the session[], and keep track of the pages...
etc.
I think that is about the best way to do it as far as I know.  Just did
this
this morning :)
John K. (Guest)
on 2006-02-15 02:31
(Received via mailing list)
What variable do you use to get the page?

On 14-Feb-06, at 7:05 PM, Dylan S. wrote:

>
> information on the net
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails


John K.
http://www.kopanas.com


=====================================================================
http://www.soen.info - source of the freshest software engineering
information on the net
http://cusec.soen.info - software engineering conference
Dylan S. (Guest)
on 2006-02-15 02:37
(Received via mailing list)
none.  when im on the first page of the form, i set something new in the
session, like:  session[:user_reg_first], with an arbitrary value.  when
they get to the second page, i do the same but with
session[:user_reg_second]...etc...etc.
if someone is on the first page, and tries to go to the third, i make
sure
they have a valid entry in session[:user_reg_third], if they don't, I
check
session[:user_reg_second]...etc

i think you get the idea.  it's a verbose method... but it works for me
:)
John K. (Guest)
on 2006-02-15 02:43
(Received via mailing list)
Wow... that is crazy :-).

For now I am going with:
<%= link_to "return without loging-in", "javascript:history.back()" %>

Unless someone has better suggestions :-).

On 14-Feb-06, at 7:34 PM, Dylan S. wrote:

>
> > did this this morning :)
> > Your Friend,
> >
>
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails


John K.
http://www.kopanas.com


=====================================================================
http://www.soen.info - source of the freshest software engineering
information on the net
http://cusec.soen.info - software engineering conference
Ben M. (Guest)
on 2006-02-15 06:32
(Received via mailing list)
I think you two were misunderstanding each other... Dylan was talking
about controlling
which page in a sequence of pages a user can go to (a "wizard"), whereas
John just wants
to create a back-button link.

N'est pas?

b

PS: John, why not just make the "back" link go the url it should? You
solution won't work
if javascript's not enabled (though we're basically turning into a
javascript or nothing
world).
Jeffrey H. (Guest)
on 2006-02-15 07:08
(Received via mailing list)
On 14-Feb-06, at 7:41 PM, John K. wrote:
> For now I am going with:
> <%= link_to "return without loging-in", "javascript:history.back()" %>
>
> Unless someone has better suggestions :-).

you can also try:
<%= link_to 'back', request.env['HTTP_REFERER'] %>

/Jeff

--
http://quotedprintable.com
Dylan S. (Guest)
on 2006-02-15 08:12
(Received via mailing list)
Ahh... true.  Well put Ben, thanks :)
John, my explanation was indeed for a wizardy/multi-step form process.
unknown (Guest)
on 2006-02-15 10:19
(Received via mailing list)
Hello,

On Tue, Feb 14, 2006 at 06:49:37PM -0500, John K. wrote:
> Are there any best practices for implementing a back/cancel/return
> button... even when the page you want to return people too is 2 pages
> back (when people submit form and then want to return)?

I use this code when I know I will have to redirect a user back:

def store_location
  session[:return_to] = request.request_uri
end

def redirect_back
  redirect_to(session[:return_to])
end

You could use session[:return_to] to create a back link.

Hope this helps!

See you

--
Damien MERENNE   <removed_email_address@domain.invalid>
http://www.cosinux.org/blogs/dam/

Chuck Norris doesnt shave; he kicks himself in the face.
The only thing that can cut Chuck Norris is Chuck Norris.
This topic is locked and can not be replied to.