2010-02-17 06:25:20 -05:00
|
|
|
module Devise
|
|
|
|
module Controllers
|
|
|
|
module ScopedViews
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
module ClassMethods
|
2010-03-26 05:01:24 -04:00
|
|
|
def scoped_views?
|
2010-02-17 06:25:20 -05:00
|
|
|
defined?(@scoped_views) ? @scoped_views : Devise.scoped_views
|
|
|
|
end
|
|
|
|
|
|
|
|
def scoped_views=(value)
|
|
|
|
@scoped_views = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
# Render a view for the specified scope. Turned off by default.
|
|
|
|
# Accepts just :controller as option.
|
2010-07-13 04:09:55 -04:00
|
|
|
def render_with_scope(action, path=self.controller_path)
|
2010-03-26 05:01:24 -04:00
|
|
|
if self.class.scoped_views?
|
2010-02-17 06:25:20 -05:00
|
|
|
begin
|
2010-07-13 04:09:55 -04:00
|
|
|
render :template => "#{devise_mapping.plural}/#{path.split("/").last}/#{action}"
|
2010-02-17 06:25:20 -05:00
|
|
|
rescue ActionView::MissingTemplate
|
2010-07-13 04:09:55 -04:00
|
|
|
render :template => "#{path}/#{action}"
|
2010-02-17 06:25:20 -05:00
|
|
|
end
|
|
|
|
else
|
2010-07-13 04:09:55 -04:00
|
|
|
render :template => "#{path}/#{action}"
|
2010-02-17 06:25:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|