Forum: Ruby on Rails How to I provoke the recalculation of a session variable?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
419c9cc258895bed66c89892721c2971?d=identicon&s=25 Elliott Blatt (eblatt)
on 2007-01-08 19:33

I've implemented a friends relationship in my user model (courtesy of
Chad Fowler, Rails Recipies) and it has worked well, until I needed to
change the order of list  of friends.

Here's the use model:

has_and_belongs_to_many :friends,
       :class_name => "User",
       :join_table => "friends_users" ,
       :association_foreign_key => "friend_id",
       :foreign_key => "user_id",
       :order => 'weight DESC '   # <------------------IMPORTANT

Here's the Table:

mysql> desc friends_users;
| Field     | Type    | Null | Key | Default | Extra |
| user_id   | int(11) | YES  |     | NULL    |       |
| friend_id | int(11) | YES  |     | NULL    |       |
| weight    | int(11) | YES  |     | 0       |       |

The idea here is that they 'weight' field will track the 'degree of
I'd like to display a users list of friends in descending order of the

The good news is that is all works...but not in real time.

For other business reasons, I have my session data lasting for 2 weeks.
Thus, it is not refreshed with every logout.  User interactions update
this weighting, and thus the cached session info becomes out of date.

The bottom line is that I'd like to stimulate the update
@session['user'].friends array in a very clean 'railsy' way.

Any thoughts?
This topic is locked and can not be replied to.