Permalink
Browse files

Show lesson's components in lessons/view

  • Loading branch information...
Evgeni Kunev
Evgeni Kunev committed Feb 17, 2012
1 parent 93bd6cd commit f2f8dfcb0c2427c0d2d126a493e4614309d1f5b3
Showing with 16 additions and 0 deletions.
  1. +5 −0 app/models/lesson.rb
  2. +11 −0 app/views/lessons/show.html.slim
View
@@ -4,4 +4,9 @@ class Lesson < ActiveRecord::Base
has_many :paragraphs
has_many :tasks
+
+ def components
+ (paragraphs + tasks).sort { |component1, component2| component1.position <=> component2.position }
+ end
+
end
@@ -13,6 +13,17 @@ p
b Language:
= link_to @lesson.language.name, language_path(@lesson.language)
+p
+ b Components:
+ -for component in @lesson.components
+ -if component.is_a? Paragraph
+ p
+ b Paragrah:
+ = component.body
+ -else
+ p Task:
+ p = component.input
+
= link_to 'Edit', edit_lesson_path(@lesson)
'|
= link_to 'Back', lessons_path

0 comments on commit f2f8dfc

Please sign in to comment.