I'm trying to figure out how to implement Acts_as_Votable in an Angular template for a car voting system. Despite my efforts, I can't seem to display the vote count when rendering the list in Angular.
I think I may need to establish some kind of association for :votes within the JSON rendered in the controller, similar to what is done with :marque. This is as far as I've gotten so far. Any help would be greatly appreciated!
Thank you
cars_controller.rb
def index
@cars = Car.all
respond_to do |format|
format.html {}
format.json {render json: @cars, :include => :marque}
end
end
index.html.erb
<div ng-repeat="car in cars | rangeFilter:slide | filter:name">
<div class="col-sm-6 col-md-4">
<ul class="thumbnail">
<li>{{car.marque.name}}</li>
<li>{{car.name}}</li>
<li>{{car.power}}</li>
<li>{{car.rotor}}</li>
<li>Votes: {{car.votes_for.size}} </li>
<li><%= link_to 'Show', URI::unescape(turbine_path('{{car.id}}'))%></li>
<li><%= link_to "up", URI::unescape(like_turbine_path('{{car.id}}')), method: :put, class: "btn btn-default btn-sm" %></li>
</ul>
</div>
</div>