Skip to content

Instantly share code, notes, and snippets.

View ikraamg's full-sized avatar
🌍
Collaborating

Ikraam Ghoor ikraamg

🌍
Collaborating
View GitHub Profile
diff --git a/core/lib/spree/core/controller_helpers/auth.rb b/core/lib/spree/core/controller_helpers/auth.rb
index 3f21ebb7c6..2112505391 100644
--- a/core/lib/spree/core/controller_helpers/auth.rb
+++ b/core/lib/spree/core/controller_helpers/auth.rb
@@ -54,6 +54,11 @@ module Spree
Spree::UserLastUrlStorer.new(self).store_location
end
+ # Auth extensions are expected to define it, otherwise it's a no-op
+ def spree_current_user
@ikraamg
ikraamg / factory_console.rb
Last active January 19, 2023 10:46
How to use factory bot in the console and also receive the errors messages from failed creations
#In rails console:
include FactoryBot::Syntax::Methods
#From: https://github.com/thoughtbot/factory_bot/issues/397#issuecomment-6662051
FactoryBot.define do
to_create do |instance|
unless instance.save
raise "Invalid record: " + instance.errors.messages.to_s
end