spree-multi-domain icon indicating copy to clipboard operation
spree-multi-domain copied to clipboard

undefined local variable or method `current_store'

Open xnjiang opened this issue 9 years ago • 4 comments

I am using spree with existing user model. After follow the instruction here: https://guides.spreecommerce.com/developer/authentication.html

I installed your gem, but I got this error:

undefined local variable or method `current_store' for #<WelcomesController:0x007fe415e475b8>

WelcomesController not need devise auth and can be view by anyone.

Here is part of log:

Started GET "/" for 127.0.0.1 at 2015-06-29 15:56:36 +0800
  ActiveRecord::SchemaMigration Load (0.6ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by WelcomesController#index as HTML
Completed 500 Internal Server Error in 15ms (ActiveRecord: 0.0ms)

NameError (undefined local variable or method `current_store' for #<WelcomesController:0x007fe415e475b8>):
  /Users/jiangxin/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/bundler/gems/spree-multi-domain-3bd641f7b354/lib/spree_multi_domain/multi_domain_helpers.rb:23:in `add_current_store_id_to_params'
  activesupport (4.2.1) lib/active_support/callbacks.rb:432:in `block in make_lambda'
  activesupport (4.2.1) lib/active_support/callbacks.rb:164:in `call'
  activesupport (4.2.1) lib/active_support/callbacks.rb:164:in `block in halting'
  activesupport (4.2.1) lib/active_support/callbacks.rb:504:in `call'
  activesupport (4.2.1) lib/active_support/callbacks.rb:504:in `block in call'
  activesupport (4.2.1) lib/active_support/callbacks.rb:504:in `each'
  activesupport (4.2.1) lib/active_support/callbacks.rb:504:in `call'
  activesupport (4.2.1) lib/active_support/callbacks.rb:92:in `_run_callbacks'
...

After I added this to application controller, I can access the app but store is empty.

  def current_store
    Spree::Store.first
  end

Did I miss something?

Thanks!

xnjiang avatar Jun 29 '15 08:06 xnjiang

i am having this same issue. did you solve it with out having to put that method in the app controller? regards

raulperezalejo avatar Aug 26 '15 19:08 raulperezalejo

I have make a pull request, please check

damonYuan avatar Oct 08 '16 01:10 damonYuan

Your WelcomesController should inherit from Spree::StoreController

ronzalo avatar Jul 13 '17 17:07 ronzalo

@ronzalo Thanks

waleolakareem avatar May 12 '19 02:05 waleolakareem