# When and how to clear some existed variables?

**URL:** <https://discuss.emberjs.com/t/when-and-how-to-clear-some-existed-variables/8080>\
**Category:** Design\
**Created:** [May 26, 2015, 12:39pm UTC](https://discuss.emberjs.com/t/when-and-how-to-clear-some-existed-variables/8080 "2015-05-26T12:39:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mojie](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mojie](https://discuss.emberjs.com/u/mojie)\
**Post date:** [May 26, 2015, 12:39pm UTC](https://discuss.emberjs.com/t/when-and-how-to-clear-some-existed-variables/8080/1 "2015-05-26T12:39:52Z")

</div>

Continuing the discussion from [Why i´m leaving ember](http://discuss.emberjs.com/t/why-i-m-leaving-ember/6361/80):

> [@Why i'm leaving ember](https://discuss.emberjs.com/t/why-im-leaving-ember/6361/80):
>
> I`m a begginer too, and agree this case very much, but I like ember more and more. I think that ember.js has no better guides, the community should improve these, how to use the nested recourses, how to resolve the flow in the controller, router or view, etc.
> 
> For example: [How to clear the pagedContent, use the willDestroy or the willDestroyElement of the View? · Issue #108 · mharris717/ember-cli-pagination · GitHub](https://github.com/mharris717/ember-cli-pagination/issues/108)
> 
> **This question is** :
> 
> I add pagination to my comments of a blog, when I transate from one blog to another, the queryParams(?page=2) and the pagedNumber are still of the one.
> 
> 1、How to clear the existed variables？
> 
> Becouse the ember-cli-pagination access the variables in the controller, I use the `willDestroy` in the comments controller, but it has no effect. The doc of the [emberjs.com](http://emberjs.com) says willDestroy called when App.reset(). I use the `init()`, it throw a null error, The code:
> 
> ```js
> willDestroy: function () {
> this.set('pagedContent.totalPages', null);
> this.set('totalPages', null);
> }
> 
> ```
> 
> The init() code: [https://github.com/onecoinim/website.onecoin.im/blob/master/app/controllers/comments.js#L27](https://github.com/onecoinim/website.onecoin.im/blob/master/app/controllers/comments.js#L27)
> 
> So I have to try another method like `willDestroyElement` of the View or the `deactive` of the route…
> 
> In this question, I don’t know (1) I should clear which variable, (2) where and how to clear it.
> 
> 2、How to access the nested resources.
> 
> This is a very easy model: blog has many comments. I have set the routes is
> 
> ```js
> 
> this.resource('blogs',function() {
> this.route('show', {path: '/:blog_id'}, function () {
> this.resource('comments', function () {
> this.route('new');
> //this.route('show', {path: ':blog_id'});
> //this.route('edit', {path: ':blog_id/edit'});
> });
> });
> });
> 
> ```
> 
> now it works, the demo is [원코인](http://onecoin.im/blogs/2/comments)
> 
> But I have a question:
> 
> If i use the url [원코인](http://onecoin.im/blogs/2) to get the same content of [원코인](http://onecoin.im/blogs/2/comments) , like the ruby on rails, How to do?
> 
> The demo: [원코인](http://onecoin.im/blogs/2/comments)
> 
> The code: [GitHub - ror/ember-cli-cms: A cms or blogger powered by Ember & Ember-cli](https://github.com/onecoinim/website.onecoin.im)
> 
> help me, thanks.
> 
> MoJie
