diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/tournament.rb | 21 | ||||
-rw-r--r-- | app/views/tournaments/_selected.html.erb | 20 |
2 files changed, 34 insertions, 7 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 3e85744..10d7b30 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -46,13 +46,20 @@ class Tournament < ActiveRecord::Base end end - def get_type(val) { - return vartypes[:true_false] if val == "true" or val == "false" - return vartypes[:range] if /\d+-\d+/ =~ val - return vartypes[:integer] if /\d+/ =~ val - return vartypes[:select] if /,/ =~ val - return vartypes[:string] - } + def get_type(val) + case val + when "true", "false" + vartypes[:true_false] + when /\d+-\d/ =~ val + vartypes[:range] + when /\d+/ =~ val + vartypes[:integer] + when /,/ =~ val + vartypes[:select] + else + vartypes[:string] + end + end def keys @tournament.preferences_raw.all.collect { |x| x.name } diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index c3a1736..d37c741 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -17,4 +17,24 @@ </p> <% end %> + <%= fields_for "tournament[preferences]", @tournament.preferences do |setting_fields| %> + <% @game.settings.each do |setting| %> + <% case setting.stype %> + <% when 0 %> + <%= setting_fields.text_field( setting.name, :name ) %> + <% when 1 %> + <%= setting_fields.text_area( setting.name, setting.name ) %> + <% when 2 %> + <%= setting_fields.collection_radio_buttons( setting.name, setting.type_opt.split(',') ) %> + <% when 3 %> + <%= setting_fields.collection_check_boxes( setting.name, setting.type_opt.split(',') ) %> + <% when 4 %> + <%= setting_fields.radio_button( setting.name, "true" ) %> + <%= setting_fields.radio_button( setting.name, "false" ) %> + <% when 5 %> + <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %> + <% end %> + <% end %> + <% end %> + <%= f.submit %> <% end %> |