0

I have app with few folders, but only one controller supported it

folder_one & folder_two, these folders should be rendered based on domain

if domain one should be rendered folder_one

How to do it?

main question is how to render folder based on request.

upd:

my app structure


accounts
 first_domain
  index.html.erb
second_domain
 index.html.erb

if request came from first_domain.com should be rendered 'accounts/index/first_domain'

if request came from 'second_domain.com' => 'accounts/index/second_domain'

Sts
  • 55
  • 5

1 Answers1

0

How can I add a view path to Rails's partial rendering lookup?

Or:

one route, one action: On controller:

def action_for_this_route
  if request.domain == 'first_domain'
    render "accounts/first_domain/index" and return
  elsif request.domain == 'second_domain'
    render "accounts/second_domain/index" and return
  end
end

Or with two different routes & actions on the controller routes.rb

root 'index#first_domain', constraints: lambda { |request| request.domain == 'first_domain' }
root 'index#second_domain', constraints: lambda { |request| request.domain == 'second_domain' }

on controller:

def first_domain
  ...
end
def second_domain
  ...
end

But I would personally render always a single "index" and inside the index partial render either first or second domain.

m3characters
  • 2,240
  • 2
  • 14
  • 18