Rails 3.2 and phonegap

前端 未结 3 1322
独厮守ぢ
独厮守ぢ 2021-02-11 01:35

I have a rails application currently running ,I want to make a mobile application for it ,I don\'t want to learn objective-c or java ,I read many articles about phonegap and how

相关标签:
3条回答
  • 2021-02-11 01:59

    This may not be the solution but an attempt on how I would do it if I were to use these technologies. The way I can see you pull this off is to use RubyonRails as Backend Sever that fetches REST API. Look here and there to see how it can be achieved. So in essence RuybOnRails server will perform fetching REST API services.

    Then, in PhoneGap you could use Backbone.js, Look here for more info, to perform your GET/POST/CRUD requests. Hope this helps.

    0 讨论(0)
  • 2021-02-11 02:03

    Obviously, there is no a single way to do this. So, I'll tell you the tools I use when have to build a mobile client working with API server app.

    Backend:

    1. Ruby on Rails
    2. rabl gem (Ruby API Builder Language) is a Rails and Padrino ruby templating system for generating JSON, XML, MessagePack, PList and BSON. With this gem you can:
      • Create arbitrary nodes named based on combining data in an object
      • Pass arguments to methods and store the result as a child node
      • Render partial templates and inherit to reduce code duplication
      • Rename or alias attributes to change the name from the model
      • Append attributes from a child into a parent node
      • Include nodes only if a certain condition has been met

    Frontend:

    1. Cordova: set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript.
    2. Angularjs (Optional)
    3. Ionic (If you choose to work with Angular): Free and open source, library of mobile-optimized HTML, CSS and JS components. Built with Sass and optimized for AngularJS. Ionic comes with an AngularJS and Cordova Seed Project example you can use to start your won app.
    4. angular-restmod (If you choose to work with Angular): Rails inspired REST-API ORM. With this you can have "javascript models" to interact with your Rails API. If you don't want to use this you can use Angular's $http

    With Ember you can use ember_phonegap_starter. This is a starter kit to get you up and running with Ember inside a mobile application. This can be dumped inside a PhoneGap wrapper to create an App wrapper for your Ember application. (check out the screencast)

    You can use bootstrap-for-ember (examples) to add Twitter Bootstrap 3 to your Ember app.

    0 讨论(0)
  • 2021-02-11 02:12

    You don't need to create a API. I had a similar situation, and used just Rails, Cordova/PhoneGap, Bootstrap, and a few Cordova plugins.

    I ran into 2 main gothchas: how to get the correct assets loaded into the app's page, and how to tell an app access from a "browser" access on the same device.

    My app required that I have a slightly different set of plugins for iOS and Android. So I needed a way to bundle up just the right set for each. I used multiple manifest files in the app/assets/javascripts directory to handle that.

    I also modified the user-agent strings coming from my Cordova apps. By default, you can't really tell a "browser" GET from a Cordova app GET.

    0 讨论(0)
提交回复
热议问题