PhoneGap and rails 3: How to interact with a rails 3 app - ruby-on-rails

totally PhoneGap newbie here, but looking to learn the basics of how to interact with a Rails 3 web app using Phonegap.
I'm looking to release a lightweight version of my Rails 3 web app as an iOS app in the appstore. I understand how PhoneGap uses CSS/HTML/JS to work but how do I tie in my Rails 3 app functionality/ruby code. Thanks a lot for any insights.

Your production rails app will live at some domain. Specify a manifest of css, js and templates to be cached locally and distributed with your app. Point your XHRs at your production rails app to fetch data and render everything locally with something like mustache.
A client-side MVC framework like Backbone is useful in this situation.
Read PhoneGap's Get Started Guide.

I'm currently working on a phonegap app integrating with .net. I do all of my interaction with my .net webservice by using xui's xhr call that return/submit either json or xml data.
Refer to the following link to read more on xui and xhr http://xuijs.com/docs/xhr

Related

How to create Login application in rails 6 using spine.js

I want to create Ruby on Rails(version 6) application using spine.js as a front end. I am not familiar with spine.js.
Can anyone help me to integrate spine.js in rails 6 application.
You can check other compatible javascript frontend framework with rails 6 which may more suitable with your application.
Check below link.
https://hackr.io/blog/10-best-javascript-frameworks-2019

How to integrate a Rails application with Angular2 in a single application?

I know there are easy ways to get AngularJS working as the front end of a Ruby on Rails application such as the angularjs-rails gem, but I haven't been able to do the same thing with Angular 2. I know I could just make 2 different applications and just have them work together, but I'd rather have them in 1 app so I can just start the one app and it'll all run and do all the testing in one app at one time.
As no "rails-angular2" gem has been released yet, you can do the integration by yourself following this link: http://programming.sereale.fr/20...
It is an example of integration without npm, but if you want to use npm you may still find a few interesting clues.

Rails 3 / PhoneGap: Converting a Rails app into an Phonegap iOS app?

I have a site built on top of Rails. In essence, I want to release a lightweight version of it for the appstore, and I think Phonegap is a good solution w/o writing a full iOS application.
What would be the easiest way to get something like this out of the door? I'm new to PhoneGap and would love if an experience dev could shed some light on how with is done. I feel it would also be a valuable resource for many other Rails devs.
My rails 3 app uses devise for authenication, carrierwave for file processing, amazon S3 for storage, and Heroku for hosting. Can someone give me some basic insight into how all these components are wrapped up and ablwe to be used with PhoneGap?
I'm new to Phonegap too, but I'm exploring the same idea than you and I've found this useful screencast: "PhoneGap + Rails 3 API"
http://vimeo.com/18763953
The idea is that you make an HTML5 client side app that makes calls to a Rails API on the server side.
Here is the code of the screencast demo:
https://github.com/quickleft/kbomb_phonegap_server (Rails API)
https://github.com/quickleft/kbomb_phonegap_client (HTML5 client with
Phonegap).
Hope it helps!
I think it could be relevant to check my phonegap-rails gem gem and my example rails / ember.js App that is exported with Phonegap. It also implements token authentication based on ember-auth and several OAuth strategies on top of Devise.
Currently in de the devel branch: https://github.com/joscas/base_app/tree/devel
Heroku deploy: https://starter-app-staging.herokuapp.com (the desktop version)
The gem exports assets, fixes paths etc. to allow seamless export of single page apps based on a rails backend.
At 37 Signals they rendered their html SERVER SIDE and just created an app wrapper. Here's the article: https://signalvnoise.com/posts/3743-hybrid-sweet-spot-native-navigation-web-content
This is an important difference in most approaches as most will re-develop their front end using a client side framework and it has the potential to save users a bunch of time. The downside is that I've heard rumors you can't get into the iOS app store, but it doesn't seem like they had a problem with it. There's also services like GoNative.io that will wrap your app for you.
A video and code that does something similar to Javi's answer can be found at
Using Phonegap as a native container for a Rails 3 App

i am developing a website with Ruby on Rails, mongoDB , JSON on a Linux. is there going to be any platform based issues for windows/Mac users?

i am developing a website which is going to use Ruby on Rails alongwith mongoDB and JSON on a Linux based platform. should i be worried for Windows/Mac users? what steps should i take to avoid any platform issues ?
And the CSS is compatible with IE7 and IE8. For a web developer, the platform of deployment most certainly will not affect your users. Its always the platform of your user that matters.
No just make sure any javascript is compatible with IE7.

Distributing Rails Applications as Native Applications

I would like to distribute a rails application as a double clickable application. When someone double clicks on the app, I think that mongrel should be started and then the user's browser should be started and open to something like localhost:3000 I'm trying to work through what I will need to do this, I think I'm going to need to include a copy of rails in the project, and a copy of the gems. Do I need to distribute ruby? Initially I'm looking to target the mac and linux for distribution. Does anyone have any experience packaging rails application like this?
The Application I'd like deploy is a media center server for a user's media. Unfortunately this means I can't have a public server serving out the media. I've built up the server using ruby on rails and rake tasks to import and manage the media. Is there a good way to make this easy for users to install? The idea was with a double clickable application it would be easy for users to bring up and down the server.
I've decided to use jruby and look into packaging the application as a java app.
The ill-fated Joyent Slingshot did exactly that, it allowed you to embed your Rails application as a standalone executable under Windows and Mac. It even provided a simple but straightforward method to allow data synchronization with an online version. Alas, it hasn't seen any activity in a long time.
https://dev.joyent.com/projects/slingshot/wiki/Slingshot
Spiceworks is a desktop-deployed Rails app, or at least it was a couple of years ago. It's a free (ad-supported) download.
Appcelerator Titanium natively supports building client-based/desktop applications using Ruby.
Hey, take a look at shopify and their theme designer app. http://vision.shopify.com/
Is pretty much exactly what your talking about. All they have done is written a stub for both platforms that launches the rails project. You can take a look at the code that checks for the rails project browsing through the vision app package contents.
I agree with the previous posters regarding desktop apps but I find myself writing web apps for the desktop (mostly widgets using Fluid) so I understand the issue. Has anyone had a look at Titanium Desktop from Appcelerator (http://www.appcelerator.com/)? I tried it initially and there was a little fiddling required, but the end result was more or less a desktop app.
If you want to write desktop apps, write desktop apps, if you want to write web apps, write web apps.
In the future, I think MacRuby will provide an excellent way to run web-apps on the desktop (well I mean OS X desktop) - you could in theory, spin up a Rails app and then have a WebView point to the Rails app. Currently, they're still focusing on making MacRuby a first-class citizen of the OS X ecosystem but Rails support is on the roadmap.
MacRuby is also exciting because of the work on the AOT compiler, with which you can compile Ruby code to machine code.

Resources