title: Sails.js: cannot do POST for inserting into mongoDB
body: <p>I am trying to write a toy program for submitting form and inserting into mongodb, but I keep getting DB error. Let me paste the relevant code here, and I hope to get some help.</p>
  
  <p>I am using Sails ver 0.10.5 and the latest mongo 2.6.5, and my I run node on my Mac OSX 10.9:</p>
  
  <p>Model: <strong>Employee.js</strong></p>
  
  <pre><code>module.exports = {
  
    attributes: {
                    name: {
                              type: "string",
                              required: true
                          },
                    email: {
                               type: "string",
                               required: true
                           },
                    password: {
                                  type: "string",
                                  required: true
                              }
    },
  beforeCreate: function(values, next) {
        next();
      }
  };
  </code></pre>
  
  <p><strong>route.js:</strong></p>
  
  <pre><code>module.exports.routes = {
  
    '/registeremployee': {
      controller: 'employee',
      action: 'register'
    },
  
    '/listemployees': {
      controller: 'employee',
      action: 'list_all'
    }
  };
  </code></pre>
  
  <p><strong>EmployeeController.js</strong></p>
  
  <pre><code>module.exports = {
  
    index: function(req, res) {
      res.send(200, {title: "employee index page"});
    },
  
    list_all: function(req, res) {
  
      Employee.find().exec(function(err, employee) {
  
        if (err) {
          res.send(500, {title: 'error retrieving users'});
        } else {
          res.send(200, {'employees': employee});
        }
      });
    },
  
    register: function(req, res) {
  
      if (req.method == "GET") {
        res.view({title: "Form for registering employees"});
      } else if (req.method == "POST") {
  
        var username = req.param("username");
        var password = req.param("password");
        var email = req.param("email");
  
        console.log("saving the username: " + username);  //username printed as 'undefined'
  
        Employee.create({username: username, password: password, email: email}).exec(function(error, employee) {
          if (error) {
            console.log('error');
            res.send(500, {error: "DB error!"});
          } else {
            console.log('error');
            res.send(200, employee);
  
            console.log("saved employee: " + employee.username);
          }
        });
      }
  
    }
  };
  </code></pre>
  
  <p>Lastly, the <strong>register.ejs</strong> template file:</p>
  
  <pre><code>&lt;a href="/listemployees"&gt;List All Users&lt;/a&gt;
  &lt;h2&gt;Form - Create a User&lt;/h2&gt;
  &lt;form action="/registeremployee" method="POST"&gt;
    &lt;table&gt;
      &lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;&lt;input type=”text” name=”username” required&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;&lt;td&gt;&lt;input type=”password” name=”password” required&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Email&lt;/td&gt;&lt;td&gt;&lt;input type=”email” name=”email” required&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit"&gt;&lt;/td&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>It looks to me that the form does not submit data, as the parameters are printed as undefined/null in my controller.</p>
  
  <p>I have this in my connections.js:</p>
  
  <pre><code>  mongo: {
      adapter: 'sails-mongo',
      host: 'localhost',
      port: 27017,
      user: '',
      password: '',
      database: 'sailsApp1'
    }
  </code></pre>