RailsCasts Pro episodes are now free!

Learn more or hide this

garbanotas's Profile

GitHub User: garbanotas

Comments by

Avatar

p.3 in this case should look like (here tags, etc. have polymorphic relations) :

class OrganizationsController < ApplicationController
def index
@organizations = Organization.all
respond_to do |format|
format.json { render :json => @organizations.to_json( :include => [:user, :tags, :emails, :phones] ) }
end
end
end

That's way angular will bind all of your nested attributes

Avatar

Hello, Jason

To have access to your models in Angular you have to do:
1. Declare your model in rails .rb file (hope you've done with this)
2. Declare model as resource in route.rb (resources :your_model )
3. Pack it to JSON in Rails Controller
4. Create angular factory with next code
angular.module('GarageCRM.resources').factory 'Your_model', ($resource) ->
$resource 'your_model'

That's all. After configuring angular routes (it's pretty simple) you'll have access to any nested model or attribute.
This should help coderberry.me