Open art-solopov opened 6 years ago
Unfortunately, the way that the loading structure works in ROM-repository requires the entities module to already exist; otherwise, it will simply create a new one -- which will kill the Rails const_missing
logic.
The best recommendation I have for you is to create a file app/models/entities.rb
and have that file either require all of your entities, or register them with autoload
:
module Entities
autoload :user 'entities/user'
end
Then require 'entities'
at the start of your repository files. It's off the Rails way, I know, and I'll need to make sure that the docs do a better job of mentioning this -- though this is a relatively new feature for rom-repository, and I'm not sure all the docs have been written for it yet.
Did you resolve that ? I cannot fix this
Edit :
It's working with (but not for repository)
module Entities
require 'entities/user'
end
There is 2 issues :
I'm trying to integrate rom on Rails, for now here my result : https://github.com/xero88/poc-rom-rb
1) Please file a different ticket
2) I need more information "Repository don't work"
3) For debugging and advice (ie, until we know what the actual error is) please use https://discourse.rom-rb.org/
4) Looking at your gemfile, I see that you're using Dry::AutoInject, and Spring. Try it without spring, and possibly try it without auto inject, if that's used in any of the repo or related. Both of those screw with the load process, and it may not be in compatible ways. If still failing, open a new ticket.
How to reproduce
rails c
:Expected
Some string printed
Actual
Additional info
This seems to be an autoloading issue since setting
config.eager_load
totrue
produces the expected result.The full code of the Rails project can be found here.