by default, when i ask rails controller to do messages/index, he does
def index
respond_to{|fmt| fmt.html}
end
and shows app/views/messages/index.html.erb
there is a customer which wants his instance of the platform to display views differently (and changes cannot be done with css only).
solution i think of would be
-
create directory app/views/#{customername}, which would have same structure as app/views, but would only have views which have to override default ones.
-
setting an array constant containing list of views which have to be overriden (if not, they should load the default views)
CUSTOM_VIEWS["messages"]=["index","show","edit"]somewhere in the customer-specific config file
-
in all controller actions do something like
def index respond_to do |fmt| fmt.html do if CUSTOM_VIEWS[params[:controller]].include?(params[:action]) #override default app/views/messages/index.html.erb with app/views/customername/messages/index.html.erb render "#{customername}/#{params[:controller]}/#{params[:action]}" end end end end
or is there better/faster solution/plugin to do that?
i believe “view_paths” along with “prepend_view_path” can be an answer to my question
for example
http://www.axehomeyg.com/2009/06/10/view-path-manipulation-for-rails-with-aop/
upd:
solved with simple add to application_controller
where APP_CONFIG[‘pr_name’] is specific product name.
basically what it does is loading custom view from app/custom_views/customername/ if it exists for specific controller action, if not it loads default view from app/views/