Using ionic with rails server


#1

Is there way to use ionic with rails server as a backend?


#2

Hey,

If you are using Angular, the best way to use your rails backend is through ngResource: http://docs.angularjs.org/api/ngResource.$resource

Then you can create a link to the remote resource like this:

var phonecatServices = angular.module('phonecatServices', ['ngResource']);
 
phonecatServices.factory('Phone', ['$resource',
  function($resource){
    return $resource('phones/:phoneId.json', {}, {
      query: {method:'GET', params:{phoneId:'phones'}, isArray:true}
    });
  }]);

#3

thanks max , If I am not using angularjs then what would be the best method to go?


#4

If you are talking about server side, you just need to print json using your server side language. Then ionic can retrieve your json data.


#5

If you want to use Rails for your app backend server you should use rails-api gem. It is a bit more lightweight.


#6

@deepender281190 if you aren’t using Angular, then you’ll want to use the AJAXy features available in your framework of choice. If you are just using something like jQuery, that means using $.ajax.

We really do recommend Angular for Ionic Alpha, because we have used some of the ngAnimate features and other things to make the framework more interactive. Right now the low-level API does not have the same functionality as the Angular portion.

At any rate, you can still use a lot of Ionic without it (like the CSS framework).