Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:52:59+00:00 2026-05-22T12:52:59+00:00

I have an application which serves more than one website. Similar to Stack Exchange,

  • 0

I have an application which serves more than one website.
Similar to Stack Exchange, these several sites behave very similarly to each other.

Given the following views directory structure:

views/
  shared/users/index.html.erb
  app1/users/index.html.erb
  app2/users/

How can I re-write the default template rendering in Rails so that

  • when App1’s UsersController#index is called, it renders app1/users/index.html.erb
  • when App2’s UsersController#index is called, it realises there is no index.html.erb template so for checks shared/users/index.html.erb before raising the missing template error

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:53:00+00:00Added an answer on May 22, 2026 at 12:53 pm

    I know you already accepted an answer for this, but I don’t think you need to create your own template resolver.

    If I understand your question correctly, you are trying to “theme” your views depending on some aspect of the current state of the app. I have done the same thing previously using this dandy little controller method:

    prepend_view_path "app/views/#{current_app_code}"
    

    Throw this in a before_filter in your application controller, and all your controllers will obey:

    class ApplicationController < ActionController::Base
      before_filter :prepend_view_paths
    
      def prepend_view_paths
        prepend_view_path "app/views/#{current_app_code}"
      end
    
    end
    

    Now rails will first look for “app/views/app1/users/index.html.erb” when “/users” is requested if “app1” is the current app.

    If it doesn’t find it there, it rolls back to the default location at “app/views/users/index.html.erb”.

    Hope this gives you another alternative.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a huge ASP.NET web application which needs to be deployed to LIVE
I have a rails application that serves as an interface to a hybrid of
We have a database server application which consists of the followings components: 1) A
I'm working on a small Rails application in which I'd like users to be
I have a rails application running on my shared host server and the public_html
I have a project coming up that involves a desktop application (tournament scoring for
If we have multiple sql server instances in a computer, how can we know
Is it possible to deploy an application to a GlassFish app server that would
I'm not so experienced but i worked on some big Java EE projects (using
I really need your help with this. We are planning on developing a real-time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.