K20GH
K20GH

Reputation: 6263

Sails 404 when loading view

I'm usings Sails, and I've just installed the sails-generate-auth package and created an api.

In my routes.js I have:

   'get /register': 'AuthController.register',

and within my AuthController I have:

  register: function (req, res) {
    res.view({
      errors: req.flash('error'),
    });
  }

I then have an ejs file called register which is located in

views/auth/register.ejs

For some reason, when I go to /register, I get a 404 message. I've turned on silly logging but it doesn't tell me much:

verbose: Sending 404 ("Not Found") response
silly: View override argument passed to res.view():  404
silly: Serving view at rel path:  404
silly: View root:  /Users/Greg/Documents/Projects/photorank-web/views

I've tried to manually specifiy the view file to load, but this doesn't seem to work either. Has anyone got any pointers as to what I could be doing wrong?

Upvotes: 1

Views: 712

Answers (1)

Alexis N-o
Alexis N-o

Reputation: 3993

How do you manually specify the view file to load?

It should look like this in the AuthController:

register: function (req, res) {
  res.view(
    'auth/register',
    { errors: req.flash('error') }
  );
}

Upvotes: 1

Related Questions