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

Load Base Controller Extension when autoloading #216

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ group :test do
gem "pg", "~> 1.0" if ENV["DB"] == "postgresql"
end

gem "solidus_support", github: "mamhoff/solidus_support", branch: "re-enable-flickwerk"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, because we do not load Solidus in this gem

Suggested change
gem "solidus_support", github: "mamhoff/solidus_support", branch: "re-enable-flickwerk"

gem "github_fast_changelog", require: false

gem "standardrb", "~> 1.0", require: false
1 change: 1 addition & 0 deletions alchemy-devise.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Gem::Specification.new do |s|

s.add_dependency "alchemy_cms", ["~> 7.0"]
s.add_dependency "devise", ["~> 4.9"]
s.add_dependency "flickwerk", ["~> 0.3.4"]

s.add_development_dependency "capybara"
s.add_development_dependency "factory_bot_rails"
Expand Down
18 changes: 0 additions & 18 deletions app/controllers/alchemy/base_controller_extension.rb

This file was deleted.

19 changes: 19 additions & 0 deletions app/patches/controllers/alchemy/devise/base_controller_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Alchemy
module Devise
module BaseControllerPatch
def self.prepended(base)
base.before_action(:store_user_request_time)
end

private

# Stores the users request time.
def store_user_request_time
if alchemy_user_signed_in?
current_alchemy_user.store_request_time!
end
end
Alchemy::BaseController.prepend self
end
end
end
6 changes: 2 additions & 4 deletions lib/alchemy/devise/engine.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require "alchemy_cms"
require "devise"
require "flickwerk"

module Alchemy
module Devise
class Engine < ::Rails::Engine
include Flickwerk
isolate_namespace Alchemy
engine_name "alchemy_devise"

Expand All @@ -16,10 +18,6 @@ class Engine < ::Rails::Engine
"alchemy-devise.css"
]
end

config.to_prepare do
require_relative "../../../app/controllers/alchemy/base_controller_extension"
end
end
end
end
Loading