Browse Source

Make Application helpers accessible to Administrate (#60)

* Expose application helpers to administrate (and other engines)

* Clarify comment
Mario Zigliotto 5 years ago
parent
commit
a2547862ab
1 changed files with 12 additions and 0 deletions
  1. 12 0
      template.rb

+ 12 - 0
template.rb

@@ -164,6 +164,16 @@ def add_administrate
     "redirect_to '/', alert: 'Not authorized.' unless user_signed_in? && current_user.admin?"
 end
 
+def add_app_helpers_to_administrate
+  environment do <<-RUBY
+    # Expose our application's helpers to Administrate
+    config.to_prepare do
+      Administrate::ApplicationController.helper #{@app_name.camelize}::Application.helpers
+    end
+  RUBY
+  end
+end
+
 def add_multiple_authentication
     insert_into_file "config/routes.rb",
     ', controllers: { omniauth_callbacks: "users/omniauth_callbacks" }',
@@ -238,6 +248,8 @@ after_bundle do
   # Migrations must be done before this
   add_administrate
 
+  add_app_helpers_to_administrate
+
   add_whenever
 
   add_sitemap