3 ms·
Awesome to see more ways of solving this problem. I usually wouldn't reach out to recommend that one to clients because the maintenance costs of doing parallel
by patio11 13y ago
Awesome to see more ways of solving this problem. I usually wouldn't reach out to recommend that one to clients because the maintenance costs of doing parallel development on three products steadily diverging from each other get quite considerable indeed, but if it works for your circumstances than awesome for you.
If hypothetically you wanted to try this with A/Bingo without making in-line calls everywhere, it's possible, but not documented anywhere. I treat the knowledge like a spell to summon the Elder Gods: too terrible a magick gained at too high a price to destroy outright, but it will certainly be buried under a forgotten temple and guarded by fanatical cultists (and maybe a dragon) to keep it from destroying the minds of the unwary.
Just kidding: it's actually just "Monkeypatch the Rails internals to change the bit which finds templates from looking in /app/views/$RAILS_CALCULATES_THIS_PART to /app/ab_tests/$YOU_CALCULATE_THIS_PART/$RAILS_CALCULATES_THIS_PART." (Though sometimes when looking at that code I wish for Cthulu's sweet embrace.)
I hear you though if you also want to do extensive logical reworking in addition to reskinning substantially all the pages of the site. The one time I did this using A/Bingo, in lieu of doing a total app rearchitecture, I made a utility method to encapsulate the A/Bingo call and then hit the 10ish points in the code base which were going to be shared but not totally equivalent between the A and B variants. A bit of a pain in the keister for a Saturday morning but the test raised sales by 60% so I'll put it in the win column.
- xionon 13y agoDisclaimer, 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.
- javiercr 13y agoIf what you want is an A/B test based on rendering different views, it's quite simple to do with the gem Split [1]: render ab_test("my_experiment", 'view_a', 'view_b') [1] https://github.com/andrew/split https://github.com/andrew/split