Forum: Ruby on Rails What does this mean?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mohammad (Guest)
on 2006-05-10 01:06
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
Michael T. (Guest)
on 2006-05-10 01:31
(Received via mailing list)
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
Mohammad (Guest)
on 2006-05-10 01:34
Michael T. 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) -= 1
Jason K. (Guest)
on 2006-05-20 18:19
(Received via mailing list)
Mohammad, you wrote,
>>     end
>>    end
>> end
>>
>> Michael
>
>That got rid of the bottom part but I still have a problem with
>@user.send(cas) -= 1

This probably is caused because the send method on your @user class is
not a
valid LHS, so you cannot assign to it.
This topic is locked and can not be replied to.