Hello.
In my controller, I have this:
user.save
if user.leveled_up==true
flash[:notice]="HOOOORAY!!!"
end
and in my model I have:
before_save :check_xp
# ....
def leveled_up=(leveled_up)
@leveled_up=leveled_up
if @leveled_up==true
self.statpoints+=5
hp=max_hp
end
end
def leveled_up
@leveled_up
end
private
def check_xp
leveled_up=false
case self.xp
when 0..999
self.level=1
when 1000..2999
leveled_up=true if self.level==1
self.level=2
when 3000..4999
leveled_up=true if self.level==2
self.level=3
when 5000..9999
leveled_up=true if self.level==3
self.level=4
# ...
end
end
But this isn't working. Even if the User leveled up the function leveled_up returns false...
I must be doing something wrong...
Thanks!!