POSTing data to rails application from an external form

Mirage

New Member
I have a HTML5 website with a form. The form data needs to be posted to my rails application, which uses the data to create a database entry. I am using jquery to post my data this way\[code\]$.post("http://localhost:3000/user/adduser",$("#userDetails").serialize(),function(data){ if(data["result"]=="success") alert("Successfully added"); else alert("FAIL");})\[/code\]And my controller is written this way\[code\] response.headers['Access-Control-Allow-Origin'] = '*' @user = User.new #Also tried with parameter = params[:users] if @user.save res = {"result"=>"success"} else res = {"result"=>"failure"} end respond_to do |format| format.json { render :json => res.to_json } end\[/code\]Somehow all the entries in my database are just NULL.
 
Back
Top