I am building a gem.
You can see my super-simple gem here: https://github.com/jasonfb/xyz_gem
It's just a shell.
What I want to know today is what tells Rails that it should load my Gem's views, that is, the views in app/views/ when loading partials?
I have a rails app called XyzGemTest (not the gem) that uses the gem via a local path include
I have view that I am rendering simply at HellosController for demonstration.
The view renders this:
this is in the app code
<%= render partial: 'hello_world' %>
Please note that my partial hello_world
is inside of my Gem-- at app/views/_hello_world.erb (although I tried also moving it to app/views/xyz_gem/_hello_world.erb -- see below)
When I load my app, I get this common error:
As you can see, this blank Rails 6.0 app is trying to load view files from presisely 3 places: (1) my own app's app/views folder (NOT the gem) (2) actiontext (3) actionmailbox
What I'm asking here is what do I need to do to my Gem to make it so that ActionView will include my gem's app/views/ folder in the 'chain' of paths that it looks for?
I tried both app/views/_hello_world.erb and also nesting _hello_world.erb into a folder called xyz_gem like so
You are welcome to fork & refactor my Github repo above.
Load paths?
application.rb has a line config.autoload_paths
I think you need to look there to find your answer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.