I'm in the proces of converting my standard Rails app to an mountable engine. The app is comparable to a standard blogging app and i want every model, controller and view to be extendable hence my choice for a mountable engine.
One of the gems i use is Devise which is as far as i understand a sort of a mountable engine itself. It can be used inside a mountable engine as stated here.
I'm able to use it partially within my engine. Everything is working fine including some Devise controller i override like this one:
# config/routes.rb
Bbronline::Engine.routes.draw do
devise_for :users, class_name: "Bbronline::User", module: :devise,
controllers: { registrations: "bbronline/devise_overrides/registrations"}
...
# controllers/bbronline/devise_overrides/registrations_controller.rb
require_dependency "bbronline/application_controller"
module Bbronline
class DeviseOverrides::RegistrationsController < Devise::RegistrationsController
def new_intermediair
@user = User.new
end
...
The correct view 'views/bbronline/devise_overrides/registrations/new_intermediair.html.haml' is also correctly loading as expected.
However my issue is that the views that i override without a custom controller are not properly loaded. For example the view that should the login view is located in views/bbronline/devise/sessions/new.html.haml
and is not loaded. Instead the standard Devise login view gets loaded i.e. devise-2.1.0/app/views/devise/sessions/new.html.erb
Of course i could solve this problem by overriding every controller with my own controller like i did with the registrations_controller above but this seems very ugly. Is overriding every controller the way to do this? Is there a more convenient way to override views from an mountable engine from within another mountable engine?
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.
If you don't want to adjust the config.railties_order
in every app that uses your engine, just require 'devise'
on top of your lib\my_engine\engine.rb file.
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