The controller.send() method failing to assign value

Hi there.

I have a conroller, on which I’m using the send() method to find the
correct property to assign a posted value to. This looks like so:

@charactersheets.send(abl) = v

Where the abl variable is defined earlier, and is a method. And the v
variable is a post value assigned earlier. I used to use a switch-case
to assign the value, and that worked fine, but this should save time,
why does it not work? I get the following error:

SyntaxError in CharactersheetsController#show

/Users/emil/Sites/ror/dnd/app/controllers/charactersheets_controller.rb:501:
syntax error, unexpected '=', expecting kEND
      @charactersheets.send(abl) = v
                                  ^
RAILS_ROOT: ./script/../config/..

Application Trace | Framework Trace | Full Trace
Request

Parameters: {"name"=>"alexander cavendor"}

Show session dump

Response

Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}

On 4 Mar 2008, at 08:33, Emil K. wrote:

Where the abl variable is defined earlier, and is a method. And the v
variable is a post value assigned earlier. I used to use a switch-case
to assign the value, and that worked fine, but this should save time,
why does it not work? I get the following error:

because the result of a method call like that isn’t an assignable
value. It’s like writing Math.sqrt(4)=3, you just can’t do it.
Assuming the variable name is foo, what you need to do is call the
foo= method, passing v as the argument.

Fred