Skip to content

Commit

Permalink
Add configurable parent class
Browse files Browse the repository at this point in the history
  • Loading branch information
virolea committed Sep 19, 2024
1 parent df9a846 commit 3c27f60
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/rosetta/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Rosetta
class ApplicationController < ActionController::Base
class ApplicationController < Rosetta.config.parent_controller_class.constantize
include Pagy::Backend
end
end
2 changes: 2 additions & 0 deletions lib/rosetta/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module Rosetta
class Configuration
attr_reader :default_locale
attr_accessor :parent_controller_class

DefaultLocale = Struct.new(:name, :code)

def initialize
set_default_locale(name: "English", code: "en")
@parent_controller_class = "ActionController::Base"
end

def set_default_locale(name:, code:)
Expand Down
1 change: 1 addition & 0 deletions test/integration/translations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TranslationsTest < ActionDispatch::IntegrationTest

# Load up the keys
get root_path(locale: locale.code)
sleep 1
key = Rosetta::TranslationKey.find_by(value: "Available locales")

# Create the translation
Expand Down

0 comments on commit 3c27f60

Please sign in to comment.