def cas casses = [@cas.ss,@cas.s,@cas.xl,@cas.l,@cas.m,@cas.w,@cas.xw] casses.each do |cas| if cas >= 10 @user.send(cas) -= 1 @user.save! end end my error: app/controllers/battle_controller.rb:383: parse error, unexpected tOP_ASGN, expecting kEND @user.send(cas) -= 1 ^ app/controllers/battle_controller.rb:388: parse error, unexpected $, expecting kEND -- Posted via http://www.ruby-forum.com/.
You''re missing an end. You should have three ends, one for the if, one for the do, one for the def. def cas casses = [@cas.ss,@cas.s,@cas.xl,@cas.l,@cas.m,@cas.w,@cas.xw] casses.each do |cas| if cas >= 10 @user.send(cas) -= 1 @user.save! end end end Michael
Michael Trier wrote:> You''re missing an end. You should have three ends, one for the if, > one for the do, one for the def. > > def cas > casses = [@cas.ss,@cas.s,@cas.xl,@cas.l,@cas.m,@cas.w,@cas.xw] > casses.each do |cas| > if cas >= 10 > @user.send(cas) -= 1 > @user.save! > end > end > end > > MichaelThat got rid of the bottom part but I still have a problem with @user.send(cas) -= 1 -- Posted via http://www.ruby-forum.com/.
Mohammad, you wrote,>Michael Trier wrote: >> You''re missing an end. You should have three ends, one for the if, >> one for the do, one for the def. >> >> def cas >> casses = [@cas.ss,@cas.s,@cas.xl,@cas.l,@cas.m,@cas.w,@cas.xw] >> casses.each do |cas| >> if cas >= 10 >> @user.send(cas) -= 1 >> @user.save! >> end >> end >> end >> >> Michael > >That got rid of the bottom part but I still have a problem with >@user.send(cas) -= 1This probably is caused because the send method on your @user class is not a valid LHS, so you cannot assign to it. -- Any alleged "right" of one man, which necessitates the violation of the rights of another, is not and cannot be a right. -- Ayn Rand