Commit 2d33fd5

mo khan <mo@mokhan.ca>
2014-04-18 19:54:31
render the video links properly.
1 parent 97bf716
Changed files (5)
app
assets
javascripts
controllers
views
app/assets/javascripts/models/video.js.coffee
@@ -1,2 +1,3 @@
 App.Video = DS.Model.extend
-  name: DS.attr('string')
+  title: DS.attr('string')
+  description: DS.attr('string')
app/assets/javascripts/templates/videos/index.hbs
@@ -1,7 +1,6 @@
 <h1>Videos Index</h1>
 <ul class="nav nav-pills nav-stacked well">
-  {{#each video in controller}}
-  {{ log video }}
-  <li> {{#link-to 'video' video}}{{video.title}}{{/link-to}} </li>
+  {{#each}}
+  <li> {{#link-to 'video' this.id}}{{title}}{{/link-to}} </li>
   {{/each}}
 </ul>
app/assets/javascripts/templates/videos.hbs
@@ -1,6 +1,6 @@
 {{outlet}}
 <ul class="nav nav-pills nav-stacked well">
-  {{#each video in controller}}
-  <li> {{#link-to 'video' video}}{{video.title}}{{/link-to}} </li>
+  {{#each}}
+  <li> {{#link-to 'video' this.id}}{{title}}{{/link-to}} </li>
   {{/each}}
 </ul>
app/controllers/videos_controller.rb
@@ -1,16 +1,8 @@
 class VideosController < ApplicationController
   def index
-    render json: [
-      {
-        id: 1,
-        title: 'getting jiggy with it',
-        description: 'supa fly funky dancing'
-      },
-      {
-        id: 2,
-        title: 'getting jiggy with it',
-        description: 'supa fly funky dancing'
-      },
+    @videos = [
+      OpenStruct.new(id: 1, title: 'getting jiggy with it', description: 'supa fly funky dancing'),
+      OpenStruct.new(id: 2, title: 'getting jiggy with it', description: 'supa fly funky dancing'),
     ]
   end
 
app/views/videos/index.jbuilder
@@ -0,0 +1,7 @@
+json.videos do
+  json.array! @videos do |video|
+    json.id video.id
+    json.title video.title
+    json.description video.description
+  end
+end