Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: What's the quickest way to port a Rails app to Android?
10 points by slaxman on Nov 10, 2013 | hide | past | favorite | 14 comments
We have a Ruby on Rails based web application. We have been getting a lot of requests for an android app from our users specifically so that they can access some data on the move even without an internet connection. What would the quickest way be?

PS: I am not looking to write the code from scratch. I am want to optimize the time to release the android app.



For fastest time to market, optimize the HTML/CSS/JavaScript to display well in a mobile browser. Detect if they are coming from mobile (requests headers like the user-agent tell you, or just optimize on screen size), and send down mobile pages. Many websites are designed with this in mind from the beginning, and services like Weebly and WPEngine will provide this in their form-built websites.

Otherwise, if your back-end has a usable API, then something like PhoneGap will be faster than writing a native Android/Java app.

Our marketing website takes the first approach, for our core app we write native Java.


Thanks! We already do serve mobile optimized content. I will checkout Phonegap for creating the app. Would it allow me to store data locally?



Phonegap seems to be a nice idea. But how do you implement CORS for such app ?


Do you need to? It's not website-to-website communication.

If you do need to it's very simple, your web server has to include some extra headers:

  "Access-Control-Allow-Origin", "*"
  "Access-Control-Allow-Methods", "GET,POST" // etc
  "Access-Control-Allow-Headers", "X-Requested-With,Content-Type"


It seems that I need to. When I don't, it gives "Origin null is not allowed by Access-Control-Allow-Origin" error.


Given that you're actually needing offline availability, the easiest way (as long as you've already got a mobile-friendly design) would probably be to deploy special wrappers for your DAOs (API classes, whatever), that perform the necessary caching to allow for it.

PhoneGap seems only interesting if you wish to commit the cached changes (or is offline = read-only?) upon regaining of connectivity.


Is your site already mobile friendly? If so, I suspect you could do a very quick and dirty HTML wrapper Android app that is simply a web browser.

Note - to any naysayers of this technique, getting an app out in the app store in this case is simply another distribution technique, even if the site is 100% identical to the web version.


I have heard that Play store rejects apps that are just a web browser. Is it true or just a rumour?


since its rails I would think it should be easy for you to create an API and then use those endpoints to retrieve data from the rails app and into the Android app.

This would mean a small amount of code on the Android side and some augmentation to how your rails app works, but its likely that your rails application already works alot like an API even if you didn't quite plan it that way by the nature of how rails lays things out for you.


OP here. yes, creating APIs is not an issue. However I have never made an android app. I was therefore looking for a tool that will help me create one quickly (even if it wasn't perfect) than write the android app from scratch.


Learn Java. Write the app. Submit to play store.


Yea, and eat javabeans in the meanwhile to survive.


Thanks. That would take too much time though. Currently priority is to get the app out of the door asap.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: