rails-image-post-solution 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c709781dda3b53150943b1146480be6d6e02b05d19aef169c8ad1a4c1c44b41
4
- data.tar.gz: 7dd5b58ac9e925252154bfdf34d48a618e5d4483d911469d888810dee3d28def
3
+ metadata.gz: 8100148b481f465bd51a674e2f58b8d523c0dc8839282b165964bb69cd8621b0
4
+ data.tar.gz: 7cb7bd81eca38077723bd9619d02426e8ff7abd00e2b7480dbf684483e9ea81e
5
5
  SHA512:
6
- metadata.gz: b0ee0eac516b61e1fef69bc18c1c77b80a9e4050337702fe9b27766b5c909dba86d924cb73db12fd74cfda083dcaf10156b7ae4abe7da15676961346c3bca5e7
7
- data.tar.gz: bf1d9b8c124994d7b7170c8aa2eecc135768078a7f3202f0d6f08a1d0970ea309f241fb5103773c8d6565f20058220f715bc16302280ed27a8e54721a901d2fe
6
+ metadata.gz: b6d48840b4c2f604623117478236ff64bf0b98193b9db15bd05f5793d84f4786bb0d202b7025060232fb40049b9cc5e1fd44b9273f3604054ecd59689f3e8470
7
+ data.tar.gz: 5eeacad90090ffbc5b141ade98ff9fa656e10c8313749ec005fcf52323940d38480744ce54a99571370baa2fc956228560f4451a9cd5b84d9a06a3e7e460f935
@@ -5,26 +5,43 @@ module RailsImagePostSolution
5
5
  # Engine's base controller inherits from host application's ApplicationController
6
6
  # This allows the engine to use the host app's authentication methods
7
7
 
8
- # Prepend engine's view path
9
- prepend_view_path Engine.root.join("app", "views")
8
+ # Include main app's route helpers
9
+ include Rails.application.routes.url_helpers
10
+ helper Rails.application.routes.url_helpers
11
+
12
+ # Add engine view path before rendering
13
+ before_action :add_engine_view_path
10
14
 
11
15
  # Override require_login to use main_app routes
12
16
  def require_login
13
17
  unless logged_in?
14
- redirect_to main_app.login_path, alert: I18n.t("errors.messages.login_required")
18
+ redirect_to login_path, alert: I18n.t("errors.messages.login_required")
15
19
  end
16
20
  end
17
21
 
18
22
  # Add require_admin method for admin controllers
19
23
  def require_admin
20
24
  unless logged_in?
21
- redirect_to main_app.login_path, alert: I18n.t("errors.messages.login_required")
25
+ redirect_to login_path, alert: I18n.t("errors.messages.login_required")
22
26
  return
23
27
  end
24
28
 
25
29
  unless current_user.admin?
26
- redirect_to main_app.root_path, alert: I18n.t("errors.messages.admin_required")
30
+ redirect_to root_path, alert: I18n.t("errors.messages.admin_required")
27
31
  end
28
32
  end
33
+
34
+ private
35
+
36
+ def add_engine_view_path
37
+ prepend_view_path Engine.root.join("app", "views")
38
+ end
39
+
40
+ # Make main_app available as a helper for engine routes
41
+ helper_method :main_app
42
+
43
+ def main_app
44
+ Rails.application.routes.url_helpers
45
+ end
29
46
  end
30
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsImagePostSolution
4
- VERSION = "0.1.20"
4
+ VERSION = "0.1.22"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-image-post-solution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler