How do you consume custom routes with ember?

0

My api rails has the route users / me that returns the data of the current user, it is written like this:

  #routes
  resources :usuarios do
    get :mim, on: :collection
  end

  #controller
  def mim
    render json: usuario_atual
  end

How can I access this route from api to ember to get user data?

    
asked by anonymous 03.11.2016 / 22:04

1 answer

1

The simplest format would be:

// rota: user.js
import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return Ember.$.ajax('http://host/user/min');
  }
});

And in the user.hbs template

Nome: {{model.name}}
    
03.07.2017 / 16:28