Skip to content

Commit 9af87f9

Browse files
author
Theresa
committed
add new dropdown for lang
1 parent 40ec9e0 commit 9af87f9

File tree

5 files changed

+10
-44
lines changed

5 files changed

+10
-44
lines changed

app/models/description.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Description < ActiveRecord::Base
22
belongs_to :exercise
33

4+
LANGUAGES= ['en', 'de','fr', 'es', 'ja', 'cn']
45

56
end

app/models/exercise.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def add_descriptions(description_array)
6262
description = Description.find(id)
6363
destroy ? description.destroy : description.update(text: array[:text], language: array[:language])
6464
else
65-
descriptions << Description.create(text: array[:text], language: language) unless destroy
65+
descriptions << Description.create(text: array[:text], language: array[:language]) unless destroy
6666
end
6767
end
6868
end

app/views/exercises/_form.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
<div class="controls" style="margin-top: 10px; margin-bottom: 10px">
3131
<%= description.text_area :text, class:'form-control' %>
3232
<%= description.remove_nested_fields_link 'Remove Description', class:'btn btn-danger btn-xs' %>
33-
<%= render 'language_dropdown_form', f: f, description: description %>
33+
<div class="field">
34+
<%= f.label :language %><br>
35+
<%= description.collection_select :language, Description::LANGUAGES, :to_s, :to_s, include_blank: false %>
36+
</div>
3437
</div>
3538
<% end %>
3639
<%= f.add_nested_fields_link :descriptions, 'Add Description', class:'btn btn-success' %>

app/views/exercises/_language_dropdown_form.html.erb

Lines changed: 0 additions & 40 deletions
This file was deleted.

app/views/exercises/show.html.erb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
<dl class="dl-horizontal">
88
<dt><%= 'Title' %>:</dt>
99
<dd><%= @exercise.title %></dd>
10-
<dt><%= 'Description' %>:</dt>
11-
<dd><%= @exercise.description %></dd>
10+
<% @exercise.descriptions.each do |description|%>
11+
<dt><%= 'Description in' %> <%= description.language %>:</dt>
12+
<dd><%= description.text %></dd>
13+
<% end %>
1214
<dt><%= 'Visibility' %>:</dt>
1315
<dd><%= @exercise.public ? 'public' : 'private' %></dd>
1416
<dt><%= 'Created by' %>:</dt>

0 commit comments

Comments
 (0)