Variable syntax questions

Two simple (I hope!) questions:

Let’s say I have a column name with a space, like (Customer Name Price).
How can I display the value of that column in a view?

@whatever.Customer Name Price doesn’t work for obvious reasons…
what’s the proper syntax to display that?

Also, is it possible to inject another variable into a variable? For
instance, I’m passing a column name as a parameter.

so… @whatever.@columnname is what I’m going for, but I’m unsure of the
proper syntax.

Thanks.!

You can use humanize method to display the column name. I don’t know if
any
database will allow defining columns with space in the name.

You can chain calls together. I don’t know what you mean by injecting a
variable.

so… @whatever.@columnname is what I’m going for, but I’m unsure of the
proper syntax.

i think what you mean is @whatever.send(@columnname) you might want
to look it up but i think that is the syntax and proper method.

Rob S. wrote:

so… @whatever.@columnname is what I’m going for, but I’m unsure of the
proper syntax.

i think what you mean is @whatever.send(@columnname) you might want
to look it up but i think that is the syntax and proper method.

Yup… thanks a lot, that’s perfect!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs