Support the ongoing development of Laravel.io →
posted 10 years ago
Requests
Last updated 2 years ago.
0

after running

php artisan routes

I get

+--------+---------------------------------------+----------------------+--------------------------------+----------------+---------------+
| Domain | URI                                   | Name                 | Action                         | Before Filters | After Filters |
+--------+---------------------------------------+----------------------+--------------------------------+----------------+---------------+
|        | GET /users                            | users.index          | UsersController@index          |                |               |
|        | GET /users/create                     | users.create         | UsersController@create         |                |               |
|        | POST /users                           | users.store          | UsersController@store          |                |               |
|        | GET /users/{users}                    | users.show           | UsersController@show           |                |               |
|        | GET /users/{users}/edit               | users.edit           | UsersController@edit           |                |               |
|        | PUT /users/{users}                    | users.update         | UsersController@update         |                |               |
|        | PATCH /users/{users}                  |                      | UsersController@update         |                |               |
|        | DELETE /users/{users}                 | users.destroy        | UsersController@destroy        |                |               |
+--------+---------------------------------------+----------------------+--------------------------------+----------------+---------------+

and my backbone model is

App.Models.User = Backbone.Model.extend({

	idAttribute : '_id',
	url			: '/users',

	validate: function(attrs){
		//Do some Validation
	}
});
Last updated 2 years ago.
0

The problem was in my model...

I had the url property set to

url: '/users'

while saving the model I had to do

App.user.save({
    'email'		: this.$('form').find('#email').val(),
    'name' 		: this.$('form').find('#name').val(),
    'password' 	: this.$('form').find('#password').val()
}, { url: '/users/' + App.user.get('_id') });

and specify the url for the PUT request

Last updated 2 years ago.
0

Try putting this line in to your backbone script

Backbone.emulateHTTP = true 

http://backbonejs.org/#Sync-emulateHTTP

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Haseeb90 haseeb90 Joined 8 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.