Forum: Ruby on Rails Making a array to use with @user.

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.
0a36dd2d45a8cead5dcfd27a9346f620?d=identicon&s=25 Mohammad (Guest)
on 2006-05-08 22:11
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?
E24b2a1d71b7365186a934a09ee6f7c3?d=identicon&s=25 Carl-Johan Kihlbom (Guest)
on 2006-05-08 22:18
(Received via mailing list)
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
0a36dd2d45a8cead5dcfd27a9346f620?d=identicon&s=25 Mohammad (Guest)
on 2006-05-08 22:31
Carl-Johan Kihlbom 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
This topic is locked and can not be replied to.