Something about dynamic segments problem?


#1

Hello, I am a new starter in ember.js, and recently i get a problem like this

Assertion Failed: You attempted to define a `{{link-to "cryptid"}}` but did not pass the parameters required for generating its dynamic segments. More context objects were passed than there are dynamic segments for the route: cryptid

I will show my code below and Anyone can explain what’s wrong and how to fix it?

in models(cryptid.js)

import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  cryptidType: DS.attr('string'),
  profileImg: DS.attr('string'),
  sightings: DS.hasMany('sighting')
});

in routes(crypteds.js)

import Route from '@ember/routing/route';

export default Route.extend({
  model(){
    return this.store.findAll('cryptid');
  }
});

in cryptids.hbs

<div class="row">
  {{#each model as |cryptid|}}
    <div class="col-xs-12 col-sm-3 text-center">
      <div class="media well">
        {{#link-to 'cryptid' cryptid.id}}
          <img class="media-object thumbnail" src="{{if cryptid.profileImg cryptid.profileImg 'assets/images/cryptids/blank_th.png'}}" alt="{{cryptid.name}}" width="100%" height="100%">
        {{/link-to}}
        <div class="caption">
          <h3>{{cryptid.name}}</h3>
        </div>
      </div>
    </div>
    {{else}}
      <div class="jumbotron">
        <h1>No Creatures</h1>
      </div>
  {{/each}}
</div>

in router.js

Router.map(function() {
  this.route('sightings', function() {
    this.route('new');
  });
  this.route('sighting', function() {
    this.route('edit');
  });
  this.route('cryptids');
  this.route('cryptid'), {path: 'cryptids/:cryptid_id'};
  this.route('witnesses');
  this.route('witness');
});


#2

Oh, It seems like that i get wrong in router.js

this.route('cryptid'), {path: 'cryptids/:cryptid_id'};

shoud be

this.route('cryptid', {path: 'cryptids/:cryptid_id'});