Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.0.11 seems to throw a filter error while routing #15

Closed
grgur opened this issue Jan 16, 2012 · 5 comments
Closed

v0.0.11 seems to throw a filter error while routing #15

grgur opened this issue Jan 16, 2012 · 5 comments

Comments

@grgur
Copy link

grgur commented Jan 16, 2012

This works ok in 0.0.10, tho. It's a simple app, something as shown in your examples. Here's the error stack.

TypeError: Cannot call method 'filter' of undefined
at /srv/myapp/node_modules/matador/node_modules/valentine/valentine.js:70:18
at Valentine.filter (/srv/myapp/node_modules/matador/node_modules/valentine/valentine.js:513:20)
at /srv/myapp/node_modules/matador/src/router.js:10:12
at callbacks (/srv/myapp/node_modules/matador/node_modules/express/lib/router/index.js:272:11)
at param (/srv/myapp/node_modules/matador/node_modules/express/lib/router/index.js:246:11)
at pass (/srv/myapp/node_modules/matador/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/srv/myapp/node_modules/matador/node_modules/express/lib/router/index.js:280:4)
at Object.handle (/srv/myapp/node_modules/matador/node_modules/express/lib/router/index.js:45:10)
at next (/srv/myapp/node_modules/matador/node_modules/express/node_modules/connect/lib/http.js:203:15)
at next (/srv/myapp/node_modules/matador/node_modules/express/node_modules/connect/lib/http.js:205:9)

@ded
Copy link
Contributor

ded commented Jan 16, 2012

what does your routes.js file look like, and what controller is handling the request, and what does the code look like that handles the beforeFilter.

  • Dustin

@grgur
Copy link
Author

grgur commented Jan 16, 2012

my routes.js

module.exports = { root: [ ['get', '/', 'Home'], ['get', '/about', 'Home', 'about'], ['get', '/registration', 'Registration', 'registration'] ] }

Excerpt from controller (called on index):

    index: function () {
          this.response.render('index', {
                locals: {
                    title: 'Some title'
                }
          })
    },```


beforeFilter is as described in matador's sample

BaseController.js
```, addBeforeFilter: function (actions, fn) {
      if (!fn) { fn = actions, actions = null }
      v(v.is.arr(actions) ? actions : [actions]).each(function (action) {
        beforeFilters.push({
            action: action
          , filter: fn
        })
      })
    }```

```beforeFilters = []```

Wish I could explain to a greater detail, but it's pretty simple, really

Grgur

@ded
Copy link
Contributor

ded commented Jan 16, 2012

i think i know what happened.... which is likely anyone upgrading to others (i should have bumped this as a minor release, instead of patch).

you'll more than likely need to change the first line of your ApplicationController.js to be this:

module.exports = require('matador').BaseController.extend(function () {

i'm pretty sure i changed over the ownership of the BaseController to be in the module, and not the scaffold

@grgur
Copy link
Author

grgur commented Jan 16, 2012

You're right, changing it to
module.exports = require('matador').BaseController.extend(function () {})
actually fixed the issue

I updated to 0.0.12, too, and it works just great

Thanks for matador, btw, It's awesome. I have it running in production here: http://sourcedevcon.eu

@grgur grgur closed this as completed Jan 16, 2012
@ded
Copy link
Contributor

ded commented Jan 16, 2012

glad that worked! super cool to see it in action :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants