# Changing url

**URL:** <https://www.ruby-forum.com/t/changing-url/144643>\
**Category:** Rails\
**Created:** [July 31, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/changing-url/144643 "2008-07-31T18:46:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 31, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/changing-url/144643/1 "2008-07-31T18:46:20Z")

</div>

I have an ajax form. When it doesn’t get saved, I just  
params[:not\_saved] = true  
render :action =\> :index

view:  
\<% if params[:not\_saved] %\>  
//show the form  
\<% end %\>

On the form, I have a link\_to\_remote “Cancel” to close the ajax form,  
but hitting cancel doesn’t change the url. This is the URL:  
[http://localhost:4000/auth\_user/save\_requirement](http://localhost:4000/auth_user/save_requirement).

rjs:  
page[:form].visual\_effect :slide\_up

How can I change the url without redirect\_to ? When a user hits  
‘cancel’, I want the URL to not include ‘/save\_requirement’ anymore.

Thanks!

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 31, 2008, 8:30pm UTC](https://www.ruby-forum.com/t/changing-url/144643/2 "2008-07-31T20:30:01Z")

</div>

You can always change the URL via the JavaScript property  
window.location. However, if you set it, you’ll get redirected to  
that URL. The standard AJAX solution is to set window.location.hash,  
which will modify the URL to indicate state change, but will not  
redirect user to a new page. More can be learned from  
[http://ajaxpatterns.org/](http://ajaxpatterns.org/),  
just search for ‘bookmarkability’.

Eric

On Jul 31, 9:46 am, Justin To [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 31, 2008, 8:54pm UTC](https://www.ruby-forum.com/t/changing-url/144643/3 "2008-07-31T20:54:54Z")

</div>

Thanks, looks promising!
