Skip to content

Commit

Permalink
Wrap use of helper_method in respond_to?
Browse files Browse the repository at this point in the history
This is considered the "safe" way to invoke `helper_method` in Rails
engines, as it is not available in some contexts, for example in
API-only applications.

Fixes solidusio#90.
  • Loading branch information
stewart committed May 22, 2017
1 parent 2600745 commit 2125897
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/spree/authentication_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module Spree
module AuthenticationHelpers
def self.included(receiver)
receiver.send :helper_method, :spree_current_user
if receiver.send(:respond_to?, :helper_method)
receiver.send(:helper_method, :spree_current_user)

if Spree::Auth::Engine.frontend_available?
receiver.send :helper_method, :spree_login_path
receiver.send :helper_method, :spree_signup_path
receiver.send :helper_method, :spree_logout_path
if Spree::Auth::Engine.frontend_available?
receiver.send(:helper_method, :spree_login_path)
receiver.send(:helper_method, :spree_signup_path)
receiver.send(:helper_method, :spree_logout_path)
end
end
end

Expand Down

0 comments on commit 2125897

Please sign in to comment.