Forum: Ruby on Rails Persistant (sticky) URL parameters?

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.
443a308e12ba2a3082fb6170ca94c2ef?d=identicon&s=25 Ed Wg (ewildgoose)
on 2007-02-23 16:14
(Received via mailing list)
Hi,  How can easily add a "persistant" or sticky parameter to my
routing, eg something like
    http://www.mysite.com/controller/action?theme=blah
or
    http://www.mysite.com/controller/action?loggedin=1

I don't want it in the session, because each browser window should have
it's own settings.  I want to add it at the application level and not
have to visit each action to add it on.

The main purpose I have for this is to implement a kind of slimmed down
theme if the site is visited via a special URL (because it's embedded in
a frame).  However, I don't want to use a cookie because if the user
visits the site normally then this should show the full theme.  I might
have also a similar use for some "cache busting" URLs where I need to
make a page slightly different for some reason, eg admin logged in,
adding "?admin=1" or something trivial to the URL makes it easier to
bust the caching so that this page is different to the standard URL

What's the easiest way to implement this so that the param remains in
place (sticky) for each URL (once set the first time)

Cheers

Ed W
20b1836f8acccd107b4992a1a45a14bd?d=identicon&s=25 chrisfarms (Guest)
on 2007-02-23 16:15
(Received via mailing list)
Cookies will be your friend here.
443a308e12ba2a3082fb6170ca94c2ef?d=identicon&s=25 Ed Wg (ewildgoose)
on 2007-02-23 16:28
(Received via mailing list)
chrisfarms wrote:
>
> Cookies will be your friend here.
>

I don't see how I can use a cookie which affects only one browser
window, but not one in the tab next door?  I would actually quite like
to know how to do this for other reasons, eg open up a second browser
window and log in as a different user without affecting the user I
logged in as on a different browser window...

If it's possible then please share

Ed W
2cbf4ec92b7b970124d6dba4df06a6e3?d=identicon&s=25 shane@thefortressofcynicism.com (Guest)
on 2007-02-23 18:21
(Received via mailing list)
Here's a snippet of where I do the exact same thing.  You have to use
or add your 'sticky_params' hash to your options hash on all the
link_to methods on that page.

If you use it all over the place you could probably extend the link_to
method in a better way to directly access a params hash in your
controller that is always appended to your options hash.

<% sticky_params = { "order_by" => 'Name' , "noun_type" =>
@noun_type } %>
<th><%= link_to( 'Name' , sticky_params  ) %></th>

Shane Sizer
866edcb271e88be4bfd935eea7947730?d=identicon&s=25 Bojan Mihelac (Guest)
on 2007-02-24 10:04
(Received via mailing list)
Ed,
did you try using default_url_options method in controller? it should
keep all params defined..

best,
Bojan

Ed W wrote:
> The main purpose I have for this is to implement a kind of slimmed down
>
> Cheers
>
> Ed W
>
> >
>


--
Bojan Mihelac
Informatika Mihelac, Bojan Mihelac s.p.  |  www.informatikamihelac.com
-> tools, scripts, tricks from our code lab: http://source.mihelac.org
This topic is locked and can not be replied to.