Created new scaffold “Users” that has fields “name” & “description”
All working as suppose to work…
Have another page that has a link that is suppose to insert new record in “Users” when clicked via ajax.
Currently when link is clicked it is inserting record but “name” & “description” fields are not populating…
Here is my jquery code for the link:
$("#test-users").click(function(){
var secure_token = $('meta[name="csrf-token"]').attr("content");
var dataString = 'authenticity_token='+ secure_token + '&name=' + 'test 1' + '&description=' + 'test 2';
$.ajax({
type: "POST",
url: "http://localhost:3000/users",
data: dataString,
success: function() {
alert('success');
}
});
return false;
});
Try it with
&user[name]=test1&user[description]=test2for the data (in addition to the token).Then make sure your controller is accessing the data via
params[:user].