I'm trying to define a method in a model to simplify things I'm doing in my controller as below:
models/game.rb
def build_array_for(words)
words.downcase.split(",")
end
I'm calling the method in the controller as below
games_controller.rb
@wordsArray = @game.build_array_for(red_words)
Note that 'red_words' is an attribute of instances of Game which value is supposed to be a string
When I call the method I get:
undefined local variable or method `red_words' for GamesController
If I build the method as:
def build_array
red_words.downcase.split(",")
end
it works but since I'm using it with other attributes for the same purpose it wouldn't make sense.
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?