How to enable query-params-new feature using ember-rails
Asked Answered
L

2

5

I am having trouble using the query-params-new feature.

My version of ember is 1.4.0-beta.2.

Ember.js is loaded into my rails app through the ember-rails and ember-source gems.

Before initializing the Ember App I turn on the feature like so.

Ember.FEATURES["query-params-new"] = true

After doing so I get the following error when navigating to any route.

Error while loading route: TypeError: Object [object Object] has no method 'paramsFor' at Ember.Route.Ember.Object.extend.deserialize

Am I missing something? Do I need to define a paramsFor method at each route?

Lilybelle answered 14/1, 2014 at 21:41 Comment(0)
P
7

I'm having the same problem, I noticed this issue mentioning the problem, and attributes it to misusing the new query params API. Where you using the prior implementation?

Edit: My problem was how I was enabling it. I was following the prior method of simply passing a value to Ember.FEATURES:

Ember.FEATURES['query-params-new'] = true;

However, the docs now specify the correct method (which also needs to happen before the Ember js file is loaded by the browser):

ENV = {FEATURES: {'query-params-new': true}};
Peppergrass answered 14/1, 2014 at 22:57 Comment(5)
Not using the prior implementation just trying to turn it on.Lilybelle
I have a feeling it is a problem with ember-rails and only loading some of the code based on load order?Lilybelle
Ok I posted an answer of my hacked solution.Lilybelle
hi its now working for me can you plese help https://mcmap.net/q/1949839/-how-to-enable-query-params-new-feature-using-ember-railsFoote
I don't see how this can work at all. Isn't ember-source going to serve the precompiled ember.js?Mandamandaean
L
3

I forgot coffee-script wraps everything in a top-level function.

Here is the way I do it in coffee-script.

#= require_self
#= require handlebars
#= require ember

@ENV = {FEATURES: {'query-params-new': true}} 
Lilybelle answered 15/1, 2014 at 1:16 Comment(2)
Glad its working. The code from the guide works for me with ember-rails as long as that ENV.FEATURES variable gets set before the Ember code loads. The error is because as soon as the code gets read into memory by the browser, an anonymous function adds paramsFor to Ember.Route if the flag exists. I just setup a separate js file with the feature code above ember in application.jsPeppergrass
If I just set ENV.FEATURES then Ember.FEATURES.isEnabled("query-params-new") returns undefined. I must be missing something because having to define Ember so that I can configure it before I load Ember seems wrong. Oh well, It works for now.Lilybelle

© 2022 - 2024 — McMap. All rights reserved.