Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Can't pass parameter to the view #142

Closed
srad opened this Issue · 3 comments

3 participants

Saman Matthew Eernisse Daniel Erickson
Saman

I have a very very weird issue when I'm trying to pass an argument from a controller to a view.

This works:

  this.show = function (req, resp, params) {
    'use strict';

    var self = this;

    geddy.model.Post.load(params.id, function (err, post) {
      self.respond({ params: params, post: post });
    });
  };

But exactly the same from the edit controller doesn't work:

  this.edit = function (req, resp, params) {
    'use strict';

    var self = this;
    geddy.model.Post.load(params.id, function (err, post) {
      console.log('\n'+JSON.stringify(post)+'\n');
      self.respond({ params: params, post: post });
    });
  };

I get this error within the view:

undefined:4
  , action = update ? '/posts' + post._id + '?_method=PUT' : '/posts'
                                 ^
ReferenceError: post is not defined

Although the "post" object exists within the controller:

{"type":"Post","saved":true,"_id":"4fb0075e356e23fb25000001","title":"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk","content":"kkkkkkkkkkkkkkkkkkkkkkkkkkk"}

"params" is completely fine send to the view.

Version:

$ node -v
v0.6.16

$ geddy -v
0.4.1

Anybody an idea what I've overlooked here?

Matthew Eernisse
Owner

Weird one. We'll take a look -- in the meantime, what happens if you hang "post" as a property on params?

Saman

That was also what I thought about, so I did this now:

  this.edit = function (req, resp, params) {
    'use strict';

    var self = this;
    geddy.model.Post.load(params.id, function (err, post) {
      params.post = post;
      self.respond({ params: params });
    });
  };

and it works. I thought the "post" key is overwritten within the "respond" method somewhere, but I couldn't see anything.
But still, probably something overwrites/deletes the property...

Daniel Erickson
Owner

Has anyone been able to reproduce this? If not, I'm going to close this.

Daniel Erickson Techwraith closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.