My model isn't creating objects and failing silently

Problem

I'm running a standard geddy setup with mongo.

Routes:

router.get('/submit').to('Urls.add');
router.post('/create').to('Urls.create');

Controller:

// invokes the form for submitting a new url
// sends form output to the create function
this.add = function (req, resp, params) {
    this.respond({params: params});
};

// creates a new url object and saves it to the database
this.create = function (req, resp, params) {
    var self = this;
    var timestamp = new Date().getTime();
    var url = geddy.model.Url.create({
        title: params.title, 
        url: params.url,
        score: 0,
        created: timestamp
    });
    url.save(function(err, data) {
        if (err) {
            params.errors = err;
            self.transfer('add');
        } else {
            this.redirect({controller: 'Url.index'});
        }
    });
};

Model:

var Url = function () {
    this.defineProperties({
        title:   {type:'string', required:true},
        url:     {type:'string', required:true},
        score:   {type:'int', required:true},
        created: {type:'datetime', required:true}
    });

    this.validatesPresent('title');
    this.validatesPresent('url');
};

Url = geddy.model.register('Url', Url);

View:

<div class="row">
<form class="form-horizontal" role="form" action="/create" method="POST">
    <div class="form-group">
        <label for="title" class="col-lg-1 control-label">Title</label>
        <div class="col-lg-7">
            <input type="text" class="form-control" id="title" placeholder="title">
        </div>
    </div>
    <div class="form-group">
        <label for="url" class="col-lg-1 control-label">URL</label>
        <div class="col-lg-7">
            <input type="text" class="form-control" id="url" placeholder="url">
        </div>
    </div>
    <div class="form-group">
        <div class="col-lg-offset-1 col-lg-7">
            <button type="submit" class="btn btn-default">Submit</button>
        </div>
    </div>
</form>
</div>

When I visit /submit and fill out the form, I just get redirected to the same form again. Nothing gets inserted in the database. This is my first time using geddy so I'm probably missing something.

Problem courtesy of: n0pe

Solution

It looks like you are not printing out the error in your view, so you can't see why it failed.

From the looks of it, it's failing because required variables are missing. You'll need name attributes on your form fields, not just id, or the server will never get your values.

Solution courtesy of: Ben

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.