It seems I must be doing something wrong here (I'm in my infancy with Spree) I followed this tutorial http://guides.spreecommerce.com/developer/authentication.html I have default devise setup and are trying now to add SpreeCommerce to it.
module Spree
module AuthenticationHelpers
def self.included(receiver)
receiver.send :helper_method, :spree_login_path
receiver.send :helper_method, :spree_signup_path
receiver.send :helper_method, :spree_logout_path
receiver.send :helper_method, :spree_current_user
end
def spree_current_user
current_user
end
def spree_login_path
# main_app.login_path
main_app.new_user_session_path
end
def spree_signup_path
main_app.new_user_registration_path
end
def spree_logout_path
main_app. destroy_user_session_path
end
end
end
Spree::BaseController.send :include, Spree::AuthenticationHelpers
ApplicationController.send :include, Spree::AuthenticationHelpers
This is my code in authentication_helpers.rb under lib/spree
I have also added following to my spree.rb initializer
Spree.user_class = "User"
Rails.application.config.to_prepare do
require_dependency 'spree/authentication_helpers'
end
I mounted spree engine under "/store"
Now. Forms for user obviously work in my application. When I go to store and I hit "Logout" that works as expected - logs me out from spree and my main app. Login form in Spree gives me following error:
> RuntimeError in Spree::UserSessionsController#create Could not find a
> valid mapping for nil
And when I look at session dump:
flash: {"discard"=>[], "flashes"=>{"success"=>"Logged in successfully"}}
session_id: "b71cbba980b1375c241d432920865fb6"
warden.user.spree_user.key: [[1], "fL1Ls3yoi8fg7yPFADbx"]
User obviously doesn't get logged in anywhere.
Registration form takes the input, saves record in Spree::User class but doesn't log user is neither allowed for login later. Login button is still there but when clicked doesn't do anything. I'm not logged in for the rest of the website either.
Additionally, when I try to open the cart I get (although /account gives no error):
ActiveRecord::AssociationTypeMismatch in Spree::OrdersController#edit
Spree::User(#70363670728860) expected, got User(#70363741439840)