I want to be able to change dynamically the view folder. The aim is to be able to change completely the web design depending on the request. I am thinking about something like this :
Class PagesController
default_views_path(current_theme_path)
def show
Blablah...
end
end
Supposing a directory architecture like this :
-apps
--views
---theme 1/show.html.erb
---theme 2/show.html.erb
---theme 3/show.html.erb
I search over the web and I have found preprend_view_path
. (:deprecated) Do you think this is a good idea ot use this ? Any feedback ?
EDIT
In fact, I want to simplify this :
Class PagesController
def show
render "#{current_theme}/show"
end
def edit
render "#{current_theme}/edit"
end
def list
render "#{current_theme}/list"
end
def index
render "#{current_theme}/index"
end
end
Any Solutions ?
You could use append_view_path. In fact, there is a comment on this append_view_path page where someone has used it for theming.
Maybe you should use layout :some_method_to_change_theme
instead? This will simplify and will keep your views DRY.
Look at this
layout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With