|Palish||Can a model's method modify the @ variables of a controller?|
|RobotDeathSquad||Is there a way to pass css "class"es to text_field_tag?|
|Palish||For 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.|
|Lathiat||you shoud do that in your controller wherever you save that|
|Lathiat||and yes yuo can pass a class iirc|
cant recall how off he top of myhead
|Palish||Is there a way to refresh a user from the database?|
@current_user.refresh or something
|RobotDeathSquad||tkx, I can't figure it out from the docs, :html => doesn't work.|
nor does :class
|pstickne||Palish, that doesn't really make sense...|
|Palish||pstickne: Well, what's happening is I'm storing a user in the session data|
|Palish||session[:current_user] = whatever_user|
|Palish||to avoid the database lookup|
but I just found out that that fails when you change anything about the user.
|pstickne||how does the session information get stored?|
|Palish||in the database.|
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
|pstickne||how would you know that without another query anyway?|
what if some other request changes the information?
|Palish||you mean like, something bypassing the model?|
say an admin renaming an account or updating a permission
|Palish||Right. 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
yeah, that's a logical flaw on my part.
I see what you're saying.