#rubyonrails - Sat 31 Mar 2007 between 04:25 and 04:34

NY Lost Funds



PalishCan a model's method modify the @ variables of a controller?
RobotDeathSquadIs there a way to pass css "class"es to text_field_tag?
PalishFor example, I have @current_user.. Whenever the user is saved, I want to detect if it's the current user, and replace @current_user with itself.
Lathiatnope
RobotDeathSquadLathiat: @me?
Lathiatyou shoud do that in your controller wherever you save that
Palish:/
Lathiatno @palish
RobotDeathSquadk
Lathiatand yes yuo can pass a class iirc
cant recall how off he top of myhead
PalishIs there a way to refresh a user from the database?
@current_user.refresh or something
RobotDeathSquadtkx, I can't figure it out from the docs, :html => doesn't work.
nor does :class
psticknePalish, that doesn't really make sense...
Palishpstickne: Well, what's happening is I'm storing a user in the session data
pstickneuhh
Palishsession[:current_user] = whatever_user
psticknewhy?
Palishto avoid the database lookup
but I just found out that that fails when you change anything about the user.
psticknehow does the session information get stored?
Palishin the database.
pstickneokay
just checking
Palish:)
Ideally it would only re-look up the user when something's changed about the user
I know! in validate I could do self.dirty = true
then in the before_filter I check @current_user.dirty
psticknehow would you know that without another query anyway?
what if some other request changes the information?
Palishyou mean like, something bypassing the model?
pstickneno.
say an admin renaming an account or updating a permission
PalishRight. So in that case, @current_user.dirty is set to true, which is stored in the session data
next request comes in, before_filter fires, checks dirty, true, look up from DB
err
yeah, that's a logical flaw on my part.
I see what you're saying.

Page: 1 8 15 22 29 36 43 50 57 64 71 78 

IrcArchive

NY Lost Funds