Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make all controllers inherit from a single DeviseController #1188

Merged
merged 1 commit into from

4 participants

@sj26

Just a simple change introducing an empty controller between devise controllers and ApplicationController. This means you can use template inheritence in rails 3.1 (a la template-inheritence, but it's rails 3.1 only then).

It also means you can move some of the shared stuff into the devise controller. (a la controller-inheritence-experimental)

Additionally, using Rails 3.1 you can easily add an extra template scope lookup, so it searches "app/views/", "app/views/devise", then "app/views/application". I'm working on this in a template-inheritence-experimental.

(Have been meaning to send this for a while...)

@josevalim
Owner

Thanks! I really like this. This is a nice first step to refactor some of this stuff out. But I have a quick question, will template inheritance really work? I still think we will need to manipulate the view paths.

@sj26

Yeah, I'm using it in template-inheritence for the footer partial (instead of devise/shared/links) :-)

@josevalim josevalim merged commit 1fdeadd into plataformatec:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 24, 2011
  1. @sj26
This page is out of date. Refresh to see the latest.
View
2  app/controllers/devise/confirmations_controller.rb
@@ -1,4 +1,4 @@
-class Devise::ConfirmationsController < ApplicationController
+class Devise::ConfirmationsController < DeviseController
include Devise::Controllers::InternalHelpers
# GET /resource/confirmation/new
View
2  app/controllers/devise/omniauth_callbacks_controller.rb
@@ -1,4 +1,4 @@
-class Devise::OmniauthCallbacksController < ApplicationController
+class Devise::OmniauthCallbacksController < DeviseController
include Devise::Controllers::InternalHelpers
def failure
View
2  app/controllers/devise/passwords_controller.rb
@@ -1,4 +1,4 @@
-class Devise::PasswordsController < ApplicationController
+class Devise::PasswordsController < DeviseController
prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
View
2  app/controllers/devise/registrations_controller.rb
@@ -1,4 +1,4 @@
-class Devise::RegistrationsController < ApplicationController
+class Devise::RegistrationsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
include Devise::Controllers::InternalHelpers
View
2  app/controllers/devise/sessions_controller.rb
@@ -1,4 +1,4 @@
-class Devise::SessionsController < ApplicationController
+class Devise::SessionsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
include Devise::Controllers::InternalHelpers
View
2  app/controllers/devise/unlocks_controller.rb
@@ -1,4 +1,4 @@
-class Devise::UnlocksController < ApplicationController
+class Devise::UnlocksController < DeviseController
prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
View
3  app/controllers/devise_controller.rb
@@ -0,0 +1,3 @@
+# All Devise controllers are inherited from here.
+class DeviseController < ApplicationController
+end
Something went wrong with that request. Please try again.