1 Reply Latest reply on Sep 26, 2015 10:50 AM by Stepan Boichyshyn

    I have create a fixed schema model with ruby code. Can i get acess to this model from js using RhomJs(5.2.2)

    Stepan Boichyshyn

      I have create a fixed schema model with ruby code. Can i get acess to this model from js using RhomJs

       

      class Cart
        include Rhom::FixedSchema
      
      
        # Uncomment the following line to enable sync with Cart.
        # enable :sync
        belongs_to :user_id, "User"
        #add model specific code here
        property :name, :string
        property :user_id, :integer
        set :schema_version, '1.1'
      end
      
      
      
      

       

      But

      var cartModel = Rho.ORM.getModel('Cart');
      function createCart(){
        var cart = cartModel.create({name: "Script Cart"});
        alert(cartModel.find("count"))
      }
      
      
      
      

      get an error -  TypeError: 'undefined' is not an object (evaluating 'cartModel.create')

       

      And

      var cartModel = Rho.ORM.addModel(function(model) {
        model.modelName('Cart');
          model.property('name','string');
      });
      
      function createCart(){
        var cart = cartModel.create({name: "Script Cart"});
        alert(cartModel.find("count"))
      
      }
      
      
      
      
      
      

      Create recirds in new PropertyBag Model called Cart

       

      Can i get access to exist FixedSchema Cart model using Js