# Rails and Firefox on crack with redirections

**URL:** <https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711>\
**Category:** Rails\
**Created:** [April 4, 2009, 4:50pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711 "2009-04-04T16:50:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 4, 2009, 4:50pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/1 "2009-04-04T16:50:11Z")

</div>

Hi,

Rails and/or Firefox are driving me nuts.

I have a products\_controllers with 2 actions: index and show.

- On the index action a session is set to create an order if user has no  
order yet.
- On that index page, user can click on a link that will bring him to  
the show action of a product where payment buttons are displayed.
- The show action is protected by a before\_filter login\_required, and a  
before filter for checking if a session[:order\_id] is present, if not he  
goes to index action.
- After logging in, user is redirected to show action, payment buttons  
appear, and his session[:order\_id] is set to nil.

All is fine up to here. So now while on show action, if user hits the  
reload button, as his session is empty, he will go to index page. That  
works.

But now, hang on tight, back on index page, if user click the refresh  
button, for some mysterious reason, he goes to the show page he  
previously visited!!! How is that possible???

And even more strange, while on the index page, if user hits enter key  
in the address bar, then the user doesn’t get redirected to show page,  
but stays on index page!?

Is that a buggy behavior from Firefox or what???

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 4, 2009, 5:03pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/2 "2009-04-04T17:03:30Z")

</div>

> Is that a buggy behavior from Firefox or what???

Damn! It’s Firefox going nuts! I tested with Safari and I don’t have  
that problem… Grrr that’s very bad!

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 4, 2009, 6:17pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/3 "2009-04-04T18:17:36Z")

</div>

On Apr 4, 3:50 pm, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> But now, hang on tight, back on index page, if user click the refresh  
> button, for some mysterious reason, he goes to the show page he  
> previously visited!!! How is that possible???

> And even more strange, while on the index page, if user hits enter key  
> in the address bar, then the user doesn’t get redirected to show page,  
> but stays on index page!?
> 
> Is that a buggy behavior from Firefox or what???

Without going into the specifics of what you have or have not done, I  
think you might need to do a little more digging: is firefox  
requesting the wrong page from your app, is it requesting the right  
page but doing something funny, is it just serving a page from its  
cache ?

Fred

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 5, 2009, 2:54pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/4 "2009-04-05T14:54:50Z")

</div>

This could be handy:

\<% req = request.env req.each do |key,value| %\> \<% end %\>

| \<%= "#{key}" %\> | \<%= "#{value}" %\> |

On Apr 4, 1:01 pm, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 6, 2009, 2:05pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/5 "2009-04-06T14:05:03Z")

</div>

Phillip wrote:

> This could be handy:
> 
> \<% req = request.env req.each do |key,value| %\> \<% end %\>
> 
> | \<%= "#{key}" %\> | \<%= "#{value}" %\> |

Interesting idea, however I couldn’t find any data concerning the  
redirection to the show page.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 4, 2009, 7:01pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/6 "2009-04-04T19:01:08Z")

</div>

> Without going into the specifics of what you have or have not done, I  
> think you might need to do a little more digging: is firefox  
> requesting the wrong page from your app, is it requesting the right  
> page but doing something funny, is it just serving a page from its  
> cache ?
> 
> Fred

Firefox requests the page that was protected by the before\_filter.  
Safari doesn’t do that.

It’s only when I use the refresh button (or ctrl+r shortcut) that  
firefox instead of refreshing the current index page, goes to the former  
/show/my\_url.

If I “refresh” manually the index page by simply pressing the Enter key  
when focus is in the address bar, it doesn’t act stupidly.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 6, 2009, 2:11pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/7 "2009-04-06T14:11:25Z")

</div>

On 4 Ð°Ð¿Ñ€, 18:50, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> - The show action is protected by a before\_filter login\_required, and a  
> button, for some mysterious reason, he goes to the show page he  
> previously visited!!! How is that possible???
> 
> And even more strange, while on the index page, if user hits enter key  
> in the address bar, then the user doesn’t get redirected to show page,  
> but stays on index page!?
> 
> ## Is that a buggy behavior from Firefox or what???
> 
> Posted viahttp://www.ruby-forum.com/.

Did you used redirect\_to or just called one action from another?  
First approach should be used.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [April 6, 2009, 2:39pm UTC](https://www.ruby-forum.com/t/rails-and-firefox-on-crack-with-redirections/164711/8 "2009-04-06T14:39:35Z")

</div>

> Did you used redirect\_to or just called one action from another?  
> First approach should be used.

At which step?

On index page, user clicks on a link like: [mysite.com/products/product-1](http://mysite.com/products/product-1)

products\_controller/show is protected by a before\_filter which  
redirect\_to a signup/login page (using restful\_auth). When user is  
identified, redirect\_back\_or\_default(‘/’) will redirect the user to  
[mysite.com/products/product-1](http://mysite.com/products/product-1) and clear session[:return\_to]

On the show page, if user hits the reload button, a redirect\_to will  
bring him back to the index. Now here is the split between Firefox and  
Safari:

- on index page, with Firefox, if user hits refresh button, he goes back  
to /products/product-1, that’s incorrect behavior.

- on index page, with Safari, if user hits refresh button, the index  
page gets refreshed. That’s the expected behavior.

So whose fault is it? Rails or Firefox?

Can you please be more accurate? I don’t see at which step I should be  
using a redirect\_to instead of a call, as I already use redirections  
where they are required (I think).

Best regards,
