@variable."field#{x}"

Ok so could anyone tell me what this is called so I can look it up
rather posting questions in this forum all the time. I have had to post
something to learn how to do the following:

Model.send("field#{x}")

and

session["field#{x}".to_sym]

now I am trying to do this for variables for example:

@details = RDetails.find(id)
1.upto(15) do |x|
  @details.???("field#{x}")
end
@details.save

I don't even know what to look up. I tried string methods, model
methods, variable methods...

Thanks in advance

Ok so could anyone tell me what this is called so I can look it up
rather posting questions in this forum all the time. I have had to post
something to learn how to do the following:

Model.send("field#{x}")

and

session["field#{x}".to_sym]

now I am trying to do this for variables for example:

@details = RDetails.find(id)
1.upto(15) do |x|
@details.???("field#{x}")
end
@details.save

I don't even know what to look up. I tried string methods, model
methods, variable methods...

What are you trying to do there? Set those fields? Otherwise I doin't see what the point is... I'm thinking you maybe want:

@details.send("field#{x}=", "some val here")

That would set all those fields to "some val here".

-philip

Sorry about that I meant to say:

@details.???("field#{x}") = "some value"

And what you said works perfect, that's exactly what I was trying to do.
I understood what the .send was doing before, I didn't realize I could
also use that to set the values as well using:

@details.send("field#{x}=", "some val here")

Thanks a lot

As a pointer, ruby is an object oriented language, that means the
objects pass messages to each other in what we commonly call
method_calls.

So, @person.first_name is a way of sending the 'first_name' message
to the @person object.

It is equiv to @person.send(:first_name)

If we wanted to set the first name of a person we could type:

@person.first_name = 'Mikel'

But we could also type:

@person.send(:first_name=, 'Mikel')

I would recommend you to get the latest version of the Pickaxe Ruby
book, it will teach you a lot about these things.

Later

Mikel
http://lindsaar.net/