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
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
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
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