Reputation: 1183
I am working on re-templating an admin portion of an app that requires rendering different views instead of the old styles. With the below, view_paths
shows that the path is prepended, but still rendering the old views.
# View folder structure
# /app
# --/views
# ----/admin
# ------/dashboard
# --------show.html.erb
# ----/admin_v2
# ------/dashboard
# --------show.html.erb
# routes.rb
constraints subdomain: 'admin' do
scope module: 'admin', as: 'admin' do
root to: 'dashboard#show'
end
end
# AdminController
class AdminController < ApplicationController
prepend_view_paths "#{Rails.root}/app/views/admin_v2"
end
# Admin::DashboardController
class Admin::DashboardController < AdminController
def show
end
end
I have moved a few things around, trying to poke holes in it, but my only guess is that it has something to do with the way my routes are structured.
Any ideas as to why?
Upvotes: 0
Views: 638
Reputation: 1183
So I figured this out myself.
It has to do with the route scope. Basically it was adding an admin prefix to my lookup_context
.
By changing my folder structure to take this into account, like below, I was able to get everything working.
# View folder structure
# /app
# --/views
# ----/admin
# ------/dashboard
# --------show.html.erb
# ----/admin_v2
# ------/admin
# --------/dashboard
# ----------show.html.erb
Upvotes: 2