Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Show lesson's components in lessons/view

  • Loading branch information...
commit f2f8dfcb0c2427c0d2d126a493e4614309d1f5b3 1 parent 93bd6cd
@kunev kunev authored
Showing with 16 additions and 0 deletions.
  1. +5 −0 app/models/lesson.rb
  2. +11 −0 app/views/lessons/show.html.slim
View
5 app/models/lesson.rb
@@ -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
View
11 app/views/lessons/show.html.slim
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.