0
我開始用導軌研究角度。這是我的問題,當我做了一個$ http.get()請求它返回和錯誤,我認爲rails不想接受數據。這是我的代碼:rails 5 - 從角度發送數據時ActionController :: UnknownFormat
查看:
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="signup_user_name">User name: </label>
<input type="text" name="instructor[user_name]" id="signup_user_name" class="form-control" required="true" ng-model="instructor.username"/>
<button type="button" class="form-control btn btn-default" ng-click="validate()">validate username</button>
</div>
</div>
</div>
控制器:
signup.controller('signupController', function($scope, $http){
$scope.validate = function() {
var username = $scope.instructor.username
var sent_data = { "username" : username };
$http.get('/home/signup', sent_data).success(
function(data, status, headers, config) {
// write code later
}).error(
function(data, status, headers, config) {
// write code later
});
}
});
軌方法:
def signup
params[:username] // trying to print the paramater sent by angular via $http.get()
end
這是結果:
Link to image result 請幫助我...謝謝! :)