I'm pretty new to the world of JavaScript and even newer to CoffeeScript. I have a problem and I'm not sure if it's even possible.
Say I have a CoffeeScript class like this
class @Model
constructor: (@name) ->
how could I pass the names of models to be created to a function to instantiate these objects whilst appending the name of the variable [in this case] with _model? Something like:
makeModel = (name) ->
"#{name}_model" = new Model(name)
My rails app tells me that:
unexpected =
"#{name}_model" = new Model(
^
I'm assuming that this is because of the string. Is there some sort of method to convert a string to a variable name? I took a quick look at the .eval() method but the little book of CoffeeScript warns against it's use.
Thanks
current_model = fred_modelSorry, complete noob here!