Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>But what I would like is to have two stores. Is it possible to do this, on a route-by-route basis?</p> </blockquote> <p>As per design you should never want to have multiple stores in your App. But instead the possibility to have an adapter on a <strong>per model basis</strong> exists.</p> <p>This would look something like this:</p> <pre><code>DS.Store.registerAdapter('App.LegacyModel', App.MyLegacyAdapter.extend({}); </code></pre> <p>If you have multiple models that use the same adapter you could do:</p> <pre><code>DS.Store.registerAdapter(['App.FooModel', 'App.BarModel'], App.MyAdapter.extend({}); </code></pre> <p>The store will then use the model type corresponding adapter when making requests.</p> <p>You can still specify a <em>default adapter</em> for the store by using the this syntax:</p> <pre><code>App.Store = DS.Store.extend({ adapter: 'DS.RESTAdapter' }); </code></pre> <p>This default adapter will be used as a fallback if you try to load a record that does not have an adapter specified for its type.</p> <blockquote> <p>Is it possible to do this, on a route-by-route basis?</p> </blockquote> <p>Following best practices, if you want to use a different model other than the one looked up by convention (e.g. using your route's name) you could do something like:</p> <pre><code>App.SomeRoute = Ember.Route.extend({ setupController: function(controller, model) { controller.set('model', App.MySpecialModel.find()); } }); </code></pre> <p>Also worth mentioning is that the <code>DS.FixtureAdapter</code> does not replace nor have the same feature set as the <code>DS.RESTAdapter</code>, it's only meant to provide simple mockup data for your app, so switching between adapter's would not work in case of the <code>DS.FixtureAdapter</code> &amp; <code>DS.RESTAdapter</code>. Use <code>DS.FixtureAdapter</code> when you don't yet care to communicate with a backend, but will store your data as "fixtures" in the client.</p> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload