I just launched a new release of www.strongside.dk based on rails 1.1.
The site is in danish so it wont make any sense to most of you.
However, here at technique I want to share with you.
Some of the pages on that site requires a lot of calculations, but the
data is actually static. So these pages are cached.
However, when a logged on user is viewing a cached page, we still want
to show him links based on his profile.
Enter, a litte rjs…
- in my layout i have:
<a href="/account/signup">Opret Profil</a> |
but when a user is logged in I want to replace these with a logout and a
view profile link.
- create a action and add a whatever.js route for it. I called my route
Just below my navigation is call this action with
- implement the action
I know, I should use the url helpers for this…
When a page is shown on the site, it only contains the login and create
It calls the rjs action through the profile.js import
The rjs action checks if its an logged in user, if so, replace the
create profile links with logout/view profile.
This technique is in part inspired by one shown previously at http://
caboo.se, but this one, using rjs is much simpler…
www.strongside.dk - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk - Buy Old Stuff!(DK)