app/controllers/storytime/application_controller.rb in storytime-0.0.1 vs app/controllers/storytime/application_controller.rb in storytime-0.0.2
- old
+ new
@@ -1,36 +1,30 @@
-module Storytime
- class ApplicationController < ActionController::Base
- # layout Storytime.layout
- rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
+class Storytime::ApplicationController < ApplicationController
+ layout Storytime.layout || "storytime/application"
+ include Pundit
+ rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
+ helper :all
- def after_sign_up_path_for(user)
- if Storytime::User.count == 1
- new_dashboard_site_url
- else
- dashboard_posts_url
- end
+ def setup
+ url = if Storytime.user_class.count == 0
+ main_app.new_user_registration_url
+ elsif current_user.nil?
+ main_app.new_user_session_url
+ elsif Storytime::Site.count == 0
+ new_dashboard_site_url
+ else
+ dashboard_posts_url
end
- def setup
- url = if User.count == 0
- new_user_registration_url
- elsif Site.count == 0
- new_dashboard_site_url
- else
- dashboard_posts_url
- end
+ redirect_to url
+ end
- redirect_to url
- end
-
- private
- def ensure_site
- redirect_to new_dashboard_site_url unless devise_controller? || @site = Site.first
- end
-
- def user_not_authorized
- flash[:error] = "You are not authorized to perform this action."
- redirect_to(request.referrer || root_path)
- end
+private
+ def ensure_site
+ redirect_to new_dashboard_site_url unless devise_controller? || @site = Storytime::Site.first
+ end
+
+ def user_not_authorized
+ flash[:error] = "You are not authorized to perform this action."
+ redirect_to(request.referrer || storytime_root_path)
end
end