From 099880a85b515ed19925c7b53502ecc476232e5b Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Fri, 24 Nov 2017 15:53:27 +0800 Subject: [PATCH] Name fallback is actually a bit confusing --- controllers/wizard.rb | 2 +- lib/builder.rb | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/controllers/wizard.rb b/controllers/wizard.rb index 05281614..7cd157ec 100644 --- a/controllers/wizard.rb +++ b/controllers/wizard.rb @@ -1,7 +1,7 @@ class CustomWizard::WizardController < ::ApplicationController prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'views')) layout 'wizard' - + before_action :ensure_logged_in helper_method :wizard_page_title diff --git a/lib/builder.rb b/lib/builder.rb index 538e95f0..160f9de2 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -40,18 +40,8 @@ class CustomWizard::Builder def self.build_post(template, user, data) post = template.gsub(/u\{(.*?)\}/) do |match| result = '' - - if USER_FIELDS.include?($1) - result = user.send($1) - if result.blank? && $1 === 'name' - result = user.send('username') - end - end - - if PROFILE_FIELDS.include?($1) - result = user.user_profile.send($1) - end - + result = user.send($1) if USER_FIELDS.include?($1) + result = user.user_profile.send($1) if PROFILE_FIELDS.include?($1) result end post.gsub!(/w\{(.*?)\}/) { |match| data[$1.to_sym] }