queryParams error when using link-to helper


#1

Hi!

I’m getting error when trying to generate link-to helper

Uncaught Error: Assertion Failed: You’re not allowed to have more than one controller property map to the same query param key, but both orders.detail:_qpMap and orders.detail.index:_qpMap map to _qpMap. You can fix this by mapping one of the controller properties to a different query param key via the as config option, e.g. _qpMap: { as: 'other-_qpMap' }

I have no query-params at all.

route table:

this.route('delivery', { path: ':deliveryPoint_id' }, function () {
                this.route('orders', { path: 'orders', resetNamespace: true }, function () {
                    this.route('detail', { path: ':order_id' });
                    this.route('archive', { path: 'history' });
                    this.route('drafts', { path: 'drafts' });                     
                });
            });

Template part inside order.index:

<p class="name">{{#link-to "orders.detail" g}}{{g.supplier.name}}{{/link-to}}</p>

#2

Workaround:

  1. Read error message

  2. Find 2 routes in message text. In this case: orders.detail and orders.detail.index

  3. Put that property in one of these routes (any)

    queryParams: { _qpMap: { as: ‘detail_qpMap’ } },

Repeat for all error messages

I had 4 different pairs of routes where this error has been raised. I don’t know why it’s happens. I think the reson maybe in resetNamespace:true


#3

I had a similar error complaining about an organizations route vs a organizations.index. I had my controller params defined in app/controllers/organizations/index.js but my query params defined in the app/routes/organizations.js. The fix that worked for me was to move the query params from app/routes/organizations.js to app/routes/organizations/index.js. Essentailly they both had to be in the index route and controller.