Module: Strongbolt::Controllers::UrlHelpers

Defined in:
lib/strongbolt/controllers/url_helpers.rb

Overview

Creates the url helpers without the ‘strongbolt_’ prefix, that both Strongbolt views and the app views can use

It’s not very nice like that but would be too complicated to do like Devise for now…

Constant Summary collapse

URLS =
%w[role user_group user_group_user role_capability].freeze

Class Method Summary collapse

Class Method Details

.create_url_helper(url, scope = nil) ⇒ Object

Creates the url helpers for the specific url and scope



17
18
19
20
21
22
23
24
25
# File 'lib/strongbolt/controllers/url_helpers.rb', line 17

def self.create_url_helper(url, scope = nil)
  %i[path url].each do |path_or_url|
    class_eval <<-URL_HELPERS
      def #{scope.present? ? "#{scope}_" : ''}#{url}_#{path_or_url} *args
        send(:main_app).send("#{scope.present? ? "#{scope}_" : ''}strongbolt_#{url}_#{path_or_url}", *args)
      end
    URL_HELPERS
  end
end