Skip to content
This repository was archived by the owner on May 28, 2020. It is now read-only.

Commit f96c1cd

Browse files
author
Mikhail Varabyou
committed
allow to configure base controller.
1 parent eceb525 commit f96c1cd

7 files changed

Lines changed: 23 additions & 5 deletions

File tree

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
open_invoice (0.1.0)
4+
open_invoice (0.1.1)
55
carrierwave-aws
66
jbuilder (~> 2.9)
77
orm_adapter (~> 0.5.0)
@@ -80,7 +80,7 @@ GEM
8080
ast (2.4.0)
8181
aws-eventstream (1.0.3)
8282
aws-partitions (1.263.0)
83-
aws-sdk-core (3.89.0)
83+
aws-sdk-core (3.89.1)
8484
aws-eventstream (~> 1.0, >= 1.0.2)
8585
aws-partitions (~> 1, >= 1.239.0)
8686
aws-sigv4 (~> 1.1)

app/controllers/open_invoice/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module OpenInvoice
44

55
# Author: varaby_m@modulotech.fr
66
# Root controller for OpenInvoice engine
7-
class ApplicationController < ::ApplicationController
7+
class ApplicationController < OpenInvoice.config.controller_base_class
88

99
include(ErrorHandling) if OpenInvoice.config.catch_engine_errors
1010
include Authenticating

config/locales/activerecord.en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ en:
2222
secure_key: Secure key
2323
open_invoice/recipient:
2424
email: Email
25-

config/open_invoice.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ orm: active_record
22
orm_base: '::ApplicationRecord'
33
storage: :aws
44
dir_prefix: uploads
5+
controller_base: '::ApplicationController'
56
mailer_base: '::ApplicationMailer'
67
mailer_layout: open_invoice/mailer
78
raise_in_development: true

lib/open_invoice/configuration.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ def mailer_default_from
141141
SUPPORTED_CACHE_STORE = %i[file_store mem_cache_store memory_store null_store
142142
redis_cache_store].freeze
143143

144+
# option to inherit base controller. defaults to "::ApplicationController"
145+
attr_accessor :controller_base
146+
147+
# controller class helper
148+
# @return [Class]
149+
def controller_base_class
150+
controller_base.constantize
151+
end
152+
144153
# option to allow errors slip through catchers and raise at the root level
145154
attr_accessor :raise_in_development
146155
# option to be the domain of the app "example.com"

lib/open_invoice/engine.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ class Engine < ::Rails::Engine
1919
Mime::Type.register 'application/pdf', :pdf
2020
end
2121

22+
# add migrations to main app
23+
initializer :append_migrations do |app|
24+
unless app.root.to_s.match root.to_s
25+
config.paths['db/migrate'].expanded.each do |expanded_path|
26+
app.config.paths['db/migrate'] << expanded_path
27+
end
28+
end
29+
end
30+
2231
end
2332

2433
end

lib/open_invoice/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module OpenInvoice
44

5-
VERSION = '0.1.0'
5+
VERSION = '0.1.1'
66

77
end

0 commit comments

Comments
 (0)