Passing an attribute name as an argument in a method not working in Rails
<p>I'm trying to define a method in a model to simplify things I'm doing in my controller as below:</p>

<p><strong>models/game.rb</strong></p>

<pre><code>def build_array_for(words)
  words.downcase.split(",")
end
</code></pre>

<p>I'm calling the method in the controller as below</p>

<p><strong>games_controller.rb</strong></p>

<pre><code>@wordsArray = @game.build_array_for(red_words)
</code></pre>

<p>Note that 'red_words' is an attribute of instances of Game which value is supposed to be a string</p>

<p>When I call the method I get:</p>

<blockquote>
  <p>undefined local variable or method `red_words' for GamesController</p>
</blockquote>

<p>If I build the method as: </p>

<pre><code>def build_array
  red_words.downcase.split(",")
end
</code></pre>

<p>it works but since I'm using it with other attributes for the same purpose it wouldn't make sense.</p>

<p>What am I missing here, could it be that the argument is passed as a string and for some reason the name of the attribute is not recognised?</p>