Somewhat simple quetion I think, but didn’t really find an answer on google..
What I want is set the current_user for a model..
So I can do different validations per user..
Something like this:
var current_user # <= this is what i need
validates, :something, :presence => { :if => :current_user_is_admin? }
def current_user_is_admin?
current_user.user_type == 1
end
So in the controller I can set the current_user before saving the record..
Hope it makes sense..
Thanks!
“var” doesn’t really make sense, because of Ruby’s slapdash style. attr_accessor may be what you want:
that defines a reader and a writer method for current_user.