2 ms·
Disclaimer, I've not used A/Bingo, so there might be a caveat I'm missing. But: It sounds like you're talking about prepend_view_path, which doesn't require mon
by xionon 13y ago
Disclaimer, I've not used A/Bingo, so there might be a caveat I'm missing. But: It sounds like you're talking about prepend_view_path, which doesn't require monkey patching.
class ApplicationController < ActionController::Base
before_filter ->() {
prepend_view_path "app/views/YOU_CALCULATE_THIS_PART"
}
end
With that, Rails should look for e.g. "products/index.html.erb" first in "app/views/YOU_CALCULATE_THIS_PART/products/index.html.erb", and only if it doesn't find it there, it looks in "app/views/products/index.html.erb"
It seems like you could do something like this:
class ApplicationController < ActionController::Base
before_filter ->() {
if cookies[:test_a]
prepend_view_path "app/views/test_a"
elsif cookies[:test_b]
prepend_view_path "app/views/test_b"
end
}
end
The neat thing about prepend_view_path is that if it doesn't find a matching file in the prepended path, it falls back to the default rails paths. This makes piecemeal upgrades or redesigns much easier.