Rails and Firefox on crack with redirections


#1

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???


#2

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!


#3

On Apr 4, 3:50 pm, Fernando P. 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


#4

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


#5

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.


#6

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.


#7

On 4 апр, 18:50, Fernando P. 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.


#8

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

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 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,