diff --git a/app/controllers/concerns/quiz_helper_methods.rb b/app/controllers/concerns/quiz_helper_methods.rb index 4b1b41c..5116e7e 100644 --- a/app/controllers/concerns/quiz_helper_methods.rb +++ b/app/controllers/concerns/quiz_helper_methods.rb @@ -39,12 +39,12 @@ private def questions_size - @questions_size ||= questions.size + 1 + @questions_size ||= questions.size end def question_index - @question_index ||= (params[:id].to_i + 1) + @question_index ||= (params[:id].to_i) end diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index f6f5163..f6586ad 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -2,11 +2,11 @@ class LanguagesController < ApplicationController before_action :set_locale_to_default, only: :index before_action :set_locale, only: :show + before_action :set_node helper_method :accept_language def index - @node = Node.roots.viewable.first not_found unless @node end @@ -14,7 +14,6 @@ class LanguagesController < ApplicationController def show @accept_language = params[:locale] - @node = Node.roots.viewable.first not_found unless @node @@ -33,6 +32,10 @@ class LanguagesController < ApplicationController private + def set_node + @node = Node.roots.viewable.first + end + def accept_language @accept_language ||= first_matching_language end @@ -42,7 +45,7 @@ private accept_languages = request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').map { |l| lang, q_factor = l.split(';q=') [lang, (q_factor || '1').to_f] - }.sort_by { |_, q| -q }.map(&:first) + }.sort_by { |_, q| -q }.map(&:first) available_languages = I18n.t('languages').keys.map(&:to_s) diff --git a/app/views/players/new.html.erb b/app/views/players/new.html.erb index 3a2bb69..53075ae 100644 --- a/app/views/players/new.html.erb +++ b/app/views/players/new.html.erb @@ -7,9 +7,9 @@
-
+
<%= t 'what_is_your_name' %> diff --git a/app/views/questions/answer.html.erb b/app/views/questions/answer.html.erb index c147c08..ff5098d 100644 --- a/app/views/questions/answer.html.erb +++ b/app/views/questions/answer.html.erb @@ -26,7 +26,7 @@ <% if question == questions.last %> <%= link_to t('see_results'), url_for(controller: 'questions', action: 'result'), class: 'button__base' %> <% else %> - <%= link_to t('next_question'), url_for(controller: 'questions', action: 'show', id: question_index), class: 'button__base' %> + <%= link_to t('next_question'), url_for(controller: 'questions', action: 'show', id: question_index.next), class: 'button__base' %> <% end %>
\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 72317ca..09bb3d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4,7 +4,7 @@ en: client_name: IKEA Foundation get_started: Let’s go! - what_is_your_name: What's your name + what_is_your_name: What's your name? please_type_your_name_here: Please type your name here… submit: Submit next_question: Next question