I have an app that varies its content based upon the domain from which
it is being accessed.  Some of the domain characteristics are
supported in the model but it is easier varying static text in the
views and then sharing the form templates via partials etc.

Rails 2.3.10 and looking at the documentation at
http://rubydoc.info/docs/rails/2.3.8/ActionController/Base#prepend_view_path-instance_method

application_controller.rb

before_filter :domain_lookup, :set_view_paths

  protected

  def set_view_paths
    self.prepend_view_path "app/views/#{controller_name}/
#{@domain.policy.policy_type}"
  end

according to the documentation this should add this path to the front
of the search order for this request only (as opposed to the similar
class method which prepends for all future requests)

I would expect the template to be rendered for the controller from app/
views/quote/type1/new.html.erb if it exists, if it does not exist it
will fall back to app/views/quote/new.html.erb

When I GET http://domain1:3000/quote/new it always renders app/views/
quote/new.html.erb and in the log I can see

Processing QuoteController#new (for 192.168.1.24 at 2011-02-21
18:47:52) [GET]
  Domain Load (0.2ms)   SELECT * FROM "domains" WHERE
("domains"."host" = 'example.com') LIMIT 1
  Policy Load (0.2ms)   SELECT * FROM "policies" WHERE
("policies"."id" = 6)
Rendering template within layouts/application
Rendering quote/new

which is incorrect.

In my development environment I also render a debug partial and in it
I have

<p><%= self.view_paths %></p>

which renders the pathset object.

views/quote/pumpapp/views

Has anyone got this working?  I was thinking of over-riding render but
am wary of any side effects.

Thanks.

O.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to