Ionic + Rails API (JPN) Flashcards

1
Q

Rails: Create the Rails Backend

A

$rails new agenda_backend -T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Rails: Create the Person Model

A

$rails g model person name phone

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Rails: Seed the test database seed.rb

A

Person.create(name: ‘Laura’, phone: ‘1800-3137977’)
Person.create(name: ‘Jeniffer’, phone: ‘1800-123456’)
Person.create(name: ‘Tom’, phone: ‘1800-654321’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Rails: Add routes to Persons

A

namespace :api, constrains: { format: :json } do
get ‘people’ => ‘agenda#all’
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Rails: Install Rack-Cors Gem (CORS = Cross origin reference sharing)

A

gem ‘rack-cors’, :require => ‘rack/cors’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Rails: Config the CORS middleware layer config > application.rb

A
config.middleware.use Rack::Cors do
    allow do
         origins '*'
         resource '*', :headers => :any, :methods => [ :get, :post, :options, :delete]
    end
end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Rails: Install Serializer Gem

A

gem ‘active_model_serializers’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Rails: Generate serializer

A

$rails g serializer person

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Rails: Config Serializer app > serializers > person_serializer.rb

A

class PersonSerializer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Rails: Generate API Controller

A

$rails g controller api/agenda all –no-helper – no-assets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Rails: Configure API Controller

A
module Api
  class Api::AgendaController
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Rails: API JSON Test

A

$ rails s

$ curl -X GET ‘http://localhost:3000/api/people’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Ionic: Generate ionic app

A

$ ionic start agenda blank

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Ionic: Add iOS/Android platform

A

$ ionic platform add ios

$ ionic platform add android

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Ionic: Config People_Controller.js www > js > controllers > people_controller.js

A

(function() {
var app = angular.module(‘peopleController’, []);
app.controller(‘PeopleController’,
function($scope, $http) {
$scope.names = [‘Jeniffer’, ‘Jackson’, ‘Jose’];
} ); })

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Ionic: Depency injection

A

www > js > app.js
angular.module(‘starter’, [‘ionic’, ‘peopleController’])

index.html

17
Q

Ionic: Ng-Repeat for PeopleController

index.html

A
<ul class="list">
     <li class="item">
        {{name}}
     </li>
   </ul>
18
Q

Rails: Find Routes for API

A

$rake routes

19
Q

Ionic: Add route to PeopleController

people_controller.js

A
app.controller('PeopleController',
   function($scope, $http) {
      var url = 'http://localhost:3000/api/people';
      $http.get(url)
         .success(function(people) {
     $scope.people = people;
                                                      })
       .error(function(data) {
     console.log('server side error occurred.'); }); } );
20
Q

Ionic: Update the interation loop in index.html

A
<ul class="list">
      <li class="item">
         <h3>{{person.name}}</h3>    
         <p>{{person.phone}}</p>
       </li>
    </ul>
21
Q

Ionic: Emulate and Test

A

$ ionic serve
$ ionic emulate/run ios
$ ionic emulate/run android