I'm having some problem accessing Rails.root
from my rails engine, that I'm creating. I need to fetch a yml config file from the main app.
Is there any "best practices" for handling configurations for your engines?
Decoding the http request TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.
Rails looks first in the application's ( test/dummy ) app/views directory and then in the engine's app/views directory. When it can't find it, it will throw this error. The engine knows to look for blorgh/comments/_comment because the model object it is receiving is from the Blorgh::Comment class.
Mounting rails are constructive items in electrical engineering and mechanical engineering projects; they are used to hold devices. A mounting rail is usually attached to a mounting panel or an enclosure profile.
Let's assume you have a module attribute for that.
# lib/my_engine.rb
module MyEngine
mattr_accessor :app_root
end
Then you can load it from the initialize block like so:
# lib/my_engine/engine.rb
module MyEngine
class Engine < Rails::Engine
initializer "my_engine.load_app_root" do |app|
MyEngine.app_root = app.root
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With