Skip to content

Instantly share code, notes, and snippets.

@shicholas
Created July 5, 2013 21:36
Show Gist options
  • Save shicholas/5937417 to your computer and use it in GitHub Desktop.
Save shicholas/5937417 to your computer and use it in GitHub Desktop.
Gon and AngularJS in a Rails 4 App
// app/assets/javascripts/controllers/funding.js
var FundingCtrl = ['$scope', function($scope) {
$scope.funding = gon.funding;
}
];
# app/controllers/funding_controller.rb
# Only showing the show action here, but this is how I'm passing a serialized Funding to Gon
class FundingsController < ApplicationController
def show
@funding = FundingDecorator.decorate(Funding.find(params[:id]))
gon.funding = FundingSerializer.new(@funding)
end
end
@shicholas
Copy link
Author

fwiw because I am using gon, I do not need ng-resource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment