4 Replies Latest reply on Mar 27, 2012 6:08 AM by steve westergaard

    Fixed Schema (Sync) - RhoConnect issues

      I'm hoping someone could shed some light on an issue that I'm having.. This is the first time I've used fixed schema models so this could be a novice error..


      I have a model named "Item" that I've changed from PropertyBag to FixedSchema. What I expect to see after my synch process is a table named "Item" appear in the syncdbuser.sqlite. This does not appear to occur.. The data does get loaded and I can see the Item contents in object_values and as in the sources table. If I attempt to query on the table I receive the following message in the log.  @items = Item.find(:all)


      I 03/26/2012 13:53:24:894 00001e1c                  APP| App error: could not prepare statement: 1; Message: no such table: Item

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rhom/rhom_db_adapter.rb:119:in `execute'

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rhom/rhom_db_adapter.rb:119:in `_execute_sql'

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rhom/rhom_db_adapter.rb:108:in `execute_sql'

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rhom/rhom_object_factory.rb:1055:in `find'

      C:/Repositories/Prototype/XXXX/Mobile/Mobile/app/helpers/managers/workorder_manager.rb:45:in `initialize'

      C:/Repositories/Prototype/XXXX/Mobile/Mobile/app/Settings/controller.rb:147:in `new'

      C:/Repositories/Prototype/XXXX/Mobile/Mobile/app/Settings/controller.rb:147:in `sync_notify'

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rho/rhocontroller.rb:91:in `serve'

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rho/rhoapplication.rb:227:in `serve'

      C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.3.beta.1.1/lib/framework/rho/rho.rb:829:in `serve'


      If I delete my rhosimulator directory then perform the following

      Code a "create" statement in application.rb  Item.create({'id' => '3'}) and query the database, the table now exists but there is no data in the table (I'd expect to see 1 row created).


      If I then run the sync process the "Item" table appears in syncdbuser.sqlite with all the data that I expect from RhoConnect [12 Rows]


      I'm not sure if this is a "beta" issue or something else, but figured I'd start here before heading to the other group which I've already scoured.

      Is ther

        • Re: Fixed Schema (Sync) - RhoConnect issues
          Robert Galvin

          Hi Steve,


          Have you looked at: http://docs.rhomobile.com/rhodes/rhom#fixed-schema


          Make sure you have it defined as a fixedschema and have the properties defined.


            include Rhom::FixedSchema
            # Uncomment the following line to enable sync with Product.
            # enable :sync
            property :name, :string
            property :brand, :string
            property :price, :string
            property :quantity, :string
            property :sku, :string
            property :int_prop, :integer
            property :float_prop, :float
            property :date_prop, :date #translate to integer type
            property :time_prop, :time #translate to integer type
          • Re: Fixed Schema (Sync) - RhoConnect issues
            Robert Galvin

            Attached is a simple project I just put together. Here are the steps I performed:


            1) Launch RhoStudio

            2) File / New Project / Rhodes Application

            3) In project New/Rhodes Model

            4) Entered Product with field names that I will use

            5) Open product.rb inthe product folder

            6) Changed PropertyBag to FixedSchema

            7) add property sections like above

            8) Hook index.erb to show Product model

            9) Run it in RhoSimulator and create/modify/view records.

              • Re: Fixed Schema (Sync) - RhoConnect issues



                Thanks but this doesn't help me in the slightest.. I understand how to make a Model as FixedSchema.. my problem has to do with RhoConnect, syncing, and the inconsistencies that I'm seeing within the latest beta version for FixedSchema vs PropertyBag. Sounds like I will need to bring this to the public group for assistance.





                1 of 1 people found this helpful
                  • Re: Fixed Schema (Sync) - RhoConnect issues

                    For anyone interested in the solution to my problem the error arose due to another model being named incorrectly.. I have refactored a number of models to follow a standard naming convention within my project as I began moving some models from PropertyBag to FixedSchema.


                    I had forgotten one model, while the sync process appeared to complete with no issue it was a bit misleading. As I had stated previously a certain fixed schema model would not appear unless I had initiated a create to insert a record.


                    After reviewing the logs I noticed the following error.

                    I 03/27/2012 08:33:50:264 00000128                  RhoRuby| require_compiled: SomeModel/some_model

                    I 03/27/2012 08:33:50:266 00000128                  APP| model name: SomeModel

                    I 03/27/2012 08:33:50:267 00000128                  APP| model class found

                    I 03/27/2012 08:33:50:267 00000128                  APP| ERROR: Invalid model definition. Add 'include Rhom::PropertyBag' or 'include Rhom::FixedSchema' to model class


                    The model was still defined as follows

                    class somemodel # rather than SomeModel

                      include Rhom::PropertyBag




                    All models prior to this one had a fixedschema table created within syncdblocal or syncdbuser.


                    The following is the correct output for the fixedschema (sync) creation, unfortunately you see that a table is created I assume (@db_partitions), but you're not notified which table was created again I assume because of the speed in which the operations are occuring, The table Item is FixedSchema while the table Barcode is of type PropertyBag. so I would correlate @db_partitions with the last model mentioned in the logfile. I would also expect an error that would notify me if a certain table was not created within the sqlite databases. Maybe this is something I need to investigate on a separate status page view that will list the tables I expect and the tables that have been created for further troubleshooting.


                    I 03/27/2012 08:56:57:662 0000197c                  APP| load_model: Item

                    I 03/27/2012 08:56:57:671 0000197c              RhoRuby| require_compiled: Item/item

                    I 03/27/2012 08:56:57:675 0000197c                  APP| model name: Item

                    I 03/27/2012 08:56:57:676 0000197c                  APP| model class found

                    I 03/27/2012 08:56:57:678 0000197c                  APP| RsItem : {"sync_type"=>"incremental", "sync_priority"=>5, "schema"=>{"property"=>{"id"=>[:string, nil]}}}

                    I 03/27/2012 08:56:57:681 0000197c                  APP| load_model: Barcode

                    I 03/27/2012 08:56:57:689 0000197c              RhoRuby| require_compiled: Barcode/barcode

                    I 03/27/2012 08:56:57:692 0000197c                  APP| model name: Barcode

                    I 03/27/2012 08:56:57:693 0000197c                  APP| model class found

                    I 03/27/2012 08:56:57:694 0000197c                  APP| RsBarcode : {"sync_type"=>"incremental", "sync_priority"=>3, "property"=>{}}

                    I 03/27/2012 08:56:57:697 0000197c                  APP| init_sources:

                    I 03/27/2012 08:56:57:701 0000197c                  APP| @db_partitions : {"user"=>#<Rhom::RhomDbAdapter:0x6298ba4 @dbpath="C:/Repositories/Prototype/XXXX/Mobile/Mobile/rhosimulator/db/syncdbuser.sqlite", @database=#<SQLite3::Database:0x6297b78>>, "local"=>#<Rhom::RhomDbAdapter:0x627cb34 @dbpath="C:/Repositories/Prototype/XXXXMobile/Mobile/rhosimulator/db/syncdblocal.sqlite", @database=#<SQLite3::Database:0x626c464>>}