Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app helper autoloading in dev and isolate namespace #8180

Merged
merged 9 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# frozen_string_literal: true
require "active_admin/base_controller/authorization"
require "active_admin/base_controller/menu"

module ActiveAdmin
# BaseController for ActiveAdmin.
# It implements ActiveAdmin controllers core features.
Expand All @@ -22,8 +19,8 @@ class << self
attr_accessor :active_admin_config
end

include Authorization
include Menu
include BaseController::Authorization
include BaseController::Menu

private

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true
require "active_admin/collection_decorator"
require "active_admin/resource_controller/action_builder"
require "active_admin/resource_controller/data_access"
require "active_admin/resource_controller/decorators"
require "active_admin/resource_controller/polymorphic_routes"
require "active_admin/resource_controller/scoping"
require "active_admin/resource_controller/streaming"
require "active_admin/resource_controller/resource_class_methods"

module ActiveAdmin
# All Resources Controller inherits from this controller.
Expand All @@ -15,12 +8,12 @@ class ResourceController < BaseController
respond_to :html, :xml, :json
respond_to :csv, only: :index

include ActionBuilder
include Decorators
include DataAccess
include PolymorphicRoutes
include Scoping
include Streaming
include ResourceController::ActionBuilder
include ResourceController::Decorators
include ResourceController::DataAccess
include ResourceController::PolymorphicRoutes
include ResourceController::Scoping
include ResourceController::Streaming
include ViewHelpers::DownloadFormatLinksHelper
extend ResourceClassMethods

Expand Down
2 changes: 1 addition & 1 deletion app/views/active_admin/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>
<%= active_admin_form_for(resource, as: resource_name, url: send(:"#{scope}_registration_path"), html: { id: "registration_new" }) do |f|
<%= active_admin_form_for(resource, as: resource_name, url: main_app.send(:"#{scope}_registration_path"), html: { id: "registration_new" }) do |f|
f.inputs do
resource.class.authentication_keys.each_with_index { |key, index|
f.input key, label: t('active_admin.devise.'+key.to_s+'.title'), input_html: { autofocus: index.zero? }
Expand Down
2 changes: 1 addition & 1 deletion app/views/active_admin/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</h2>

<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= active_admin_form_for(resource, as: resource_name, url: send(:"#{scope}_session_path")) do |f|
<%= active_admin_form_for(resource, as: resource_name, url: main_app.send(:"#{scope}_session_path")) do |f|
f.inputs do
resource.class.authentication_keys.each_with_index { |key, index|
f.input key, label: t("active_admin.devise.#{key}.title"), input_html: { autofocus: index.zero? }
Expand Down
2 changes: 1 addition & 1 deletion app/views/active_admin/devise/shared/_links.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="mt-6 text-sm link-default">
<%- if controller_name != 'sessions' %>
<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= link_to t('active_admin.devise.links.sign_in'), send(:"new_#{scope}_session_path") %>
<%= link_to t('active_admin.devise.links.sign_in'), main_app.send(:"new_#{scope}_session_path") %>
<br>
<% end -%>

Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/comment_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
end

When /^I add a comment "([^"]*)"$/ do |comment|
step %{I fill in "active_admin_comment_body" with "#{comment}"}
step %{I fill in "comment_body" with "#{comment}"}
step %{I press "Add Comment"}
end

Expand Down
3 changes: 0 additions & 3 deletions lib/active_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module ActiveAdmin
autoload :AuthorizationAdapter, "active_admin/authorization_adapter"
autoload :Callbacks, "active_admin/callbacks"
autoload :Component, "active_admin/component"
autoload :BaseController, "active_admin/base_controller"
autoload :CanCanAdapter, "active_admin/cancan_adapter"
autoload :ControllerAction, "active_admin/controller_action"
autoload :CSVBuilder, "active_admin/csv_builder"
Expand All @@ -36,11 +35,9 @@ module ActiveAdmin
autoload :OrderClause, "active_admin/order_clause"
autoload :Page, "active_admin/page"
autoload :PagePresenter, "active_admin/page_presenter"
autoload :PageController, "active_admin/page_controller"
autoload :PageDSL, "active_admin/page_dsl"
autoload :PunditAdapter, "active_admin/pundit_adapter"
autoload :Resource, "active_admin/resource"
autoload :ResourceController, "active_admin/resource_controller"
autoload :ResourceDSL, "active_admin/resource_dsl"
autoload :Scope, "active_admin/scope"
autoload :ScopeChain, "active_admin/helpers/scope_chain"
Expand Down
2 changes: 2 additions & 0 deletions lib/active_admin/engine.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true
module ActiveAdmin
class Engine < ::Rails::Engine
isolate_namespace ActiveAdmin

# Set default values for app_path and load_paths before running initializers
initializer "active_admin.load_app_path", before: :load_config_initializers do |app|
ActiveAdmin::Application.setting :app_path, app.root
Expand Down