Hi,

I have the current use case in which I save the current website page in a 
cookie. Nothing that other platforms don't do (correct me if I'm wrong, but 
Facebook and Twitter do this currently). Now, I have two ways to accomplish 
that: the JS way and the no-JS way.

JS: I update the cookie on the client side and redirect myself to the 
location url. 

no-JS: I trigger a POST request to a known URL with the language code, 
update the cookie on the server side and then redirect the user to the 
referrer url. 

The no-JS is a bit under-performant for two reasons: First one is, I have 
to go through all the app stack in order to reach the action where I will 
update the cookie and generate my redirection response. The other one is, 
every language change equals two requests: one for setting the cookie and 
another one for redirection. Second problem is a bit hard to solve and 
doesn't belong to the rails scope, but the first one does. 

My first try involved redirecting directly from the route, which is 
possible since Rails 3. It was all going dandy, until I saw I have no 
access to the response, and therefore to its cookies. The redirection I'm 
allowed to create doesn't give me access to its headers either. So, my 
dream solution of setting the response cookies directly in the route never 
came to be.

This is something I would like to see as a Rails feature. I don't know what 
would be the arguments against it, that's why I would like to open this 
thread to debate on the topic.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/Bt_eHcDLcLEJ.
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-core?hl=en.

Reply via email to