0

I have web application written with Spine.js. It has 2 language translations. I want to store current application's translation in Spine Model.

My model:

class Translation extends Spine.Model

    @configure "Translation", "lang"

    @getLang: ->
        Translation.all()

module.exports = Translation

I have function which changes translation in application and i save new translation to the model in this function:

  changeLang: (locale) ->
    lang = Translation.create({lang: locale})
    lang.save()

But when i try to fetch data from Translation model from another controller i get empty result:

Translation = require("models/translation")
...
alert(Translation.getLang())

I got empty alert. How can i make it correctly?

Thank you.

0xAX
  • 20,957
  • 26
  • 117
  • 206

1 Answers1

0

The Translation.all() returns copies of all instances of Translation class. It seems, from snippets you provided, that when you call Translation.getLang() there are no such instances. You should make sure that changeLang has been called (I suppose that it is the only place where new instances of Translation are created) before calling alert(Translation.getLang()).

Prvaak
  • 757
  • 1
  • 6
  • 13