Elliott Blatt
2007-Jan-08 18:33 UTC
How to I provoke the recalculation of a session variable?
Hi, 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 friendship''. I''d like to display a users list of friends in descending order of the ''weight'' 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---