Skip to content

Instantly share code, notes, and snippets.

@yihangho yihangho/gist:c2b78ec9edf69868b0e1 Secret
Last active Aug 29, 2015

What would you like to do?
<!DOCTYPE html>
<meta charset="utf-8">
<title>Rails CORS</title>
<body ng-app="app">
<div ng-controller="PostController">
<li ng-repeat="post in posts">{{ post }}</li>
Delete status: {{ deleteStatus }}.
<script src="//"></script>
var app = angular.module('app', []);
app.controller('PostController', ['$scope', '$http', function($scope, $http) {
$scope.deleteStatus = "ongoing";
$http.get('http://localhost:3000/posts.json').success(function(data) {
$scope.posts = data;
}).error(function() {
console.log("Error getting posts")
$scope.deleteStatus = "done";
}).error(function() {
$scope.deleteStatus = "error";

This comment has been minimized.

Copy link

commented Mar 6, 2015

I'm getting exactly the same CORS error. Running rails sever on port 3000, running an http-server on port 8080 on Chrome, this code doesn't work.

edit: same thing on Firefox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.