]> cat aescling's git repositories - mastodon.git/commitdiff
Fix #611 - Layout setting in registrations controller
authorEugen <eugen@zeonfederated.com>
Wed, 8 Feb 2017 02:04:29 +0000 (03:04 +0100)
committerGitHub <noreply@github.com>
Wed, 8 Feb 2017 02:04:29 +0000 (03:04 +0100)
app/controllers/auth/registrations_controller.rb

index b7d019c2459a9e12fe9fdd0ca267e5857de438f3..501e66807609397629ac9f5578a3a1fab566734f 100644 (file)
@@ -1,8 +1,7 @@
 # frozen_string_literal: true
 
 class Auth::RegistrationsController < Devise::RegistrationsController
-  layout 'auth'
-  layout 'admin', only: [:edit]
+  layout :determine_layout
 
   before_action :check_single_user_mode
   before_action :configure_sign_up_params, only: [:create]
@@ -31,4 +30,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController
   def check_single_user_mode
     redirect_to root_path if Rails.configuration.x.single_user_mode
   end
+  
+  private
+  
+  def determine_layout
+    %w(edit update).include?(action_name) ? 'admin' : 'auth'
+  end
 end