Sabo
10/03/2022, 6:31 AMNameError in Spree::UserSessionsController#create
Rails couldn't find a valid model for User association. Please provide the :class_name option on the association declaration. If :class_name is already provided, make sure it's an ActiveRecord::Base subclass.
Extracted source (around line #19):
authenticate_spree_user!
if spree_user_signed_in?
respond_to do |format|
format.html do
flash[:success] = I18n.t('spree.logged_in_succesfully')
app/controllers/spree/user_sessions_controller.rb:19:in `create'
Exception Causes
NameError: uninitialized constant Ahoy::Visit::User raise NameError.new("uninitialized constant #{candidates.first}", candidates.first) ^^^^^
There is not Ahoy::Visit::User
I guess the controller is looking for Spree::User
?
The issue :
https://github.com/ankane/ahoy/issues/513elia
10/03/2022, 9:13 AMcurrent_user
method to match the one used by solidus? Ahoy.user_method = :spree_current_user
Sabo
10/03/2022, 2:32 PMAhoy.user_method = :spree_current_user
into initializers/ahoy.rb
but still the same error
class Ahoy::Store < Ahoy::DatabaseStore
end
# set to true for JavaScript tracking
Ahoy.api = false
# set to true for geocoding (and add the geocoder gem to your Gemfile)
# we recommend configuring local geocoding as well
# see <https://github.com/ankane/ahoy#geocoding>
Ahoy.geocode = false
Ahoy.user_method = :spree_current_user
elia
10/04/2022, 11:03 AMclass Ahoy::Visit < ApplicationRecord
self.table_name = "ahoy_visits"
has_many :events, class_name: "Ahoy::Event"
belongs_to :user, optional: true
end
If that’s the case you should adjust the belongs_to
association to point toward Spree::User
instead of a generic User
, adding class_name: 'Spree::User'
should be enoughSabo
10/04/2022, 1:52 PM