LoadError Unable to autoload constant Message

By convention in rails (and this is enforced by autoloader), file paths should match namespaces.

So, if you have a Mailboxer::Message model, it should be in app/models/mailboxer/message.rb.

Additionally, you probably have autoloader kicking in when trying to load a Message class (my guess is that it happens from within ActAsMessageable). It looks for a message.rb file in the load path, finds it in app/model/ and thus loads that file so it can find the Message class.

Problem is, it doesn’t find a Message class in that file, only a Mailboxer::Message class (which is different). This is why it throws “Unable to autoload constant Message, expected /app/models/message.rb to define it”.

To fix that, create directory app/models/mailboxer/ and put Mailboxer::Message in it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)