Making a array to use with @user


#1

Hi all,
I made this array:
@army_types = [“ss”,“s”,“xl”,“l”,“m”,“w”,“xw”]
but, I want to be able to go like this
@army_types.each do |st|
@user.st
end
but, I get the error that “@user.st” st is not a valid feild for the
table user.
Is there a way to get around MySQL running it first?


#2

It’s not entirely clear to my what you want to do. But if I understand
correctly, you should try this:

@army_types.each do |st|
@user.send(st)
end


#3

Carl-Johan K. wrote:

It’s not entirely clear to my what you want to do. But if I understand
correctly, you should try this:

@army_types.each do |st|
@user.send(st)
end

Thanks this worked