0

I'm trying to have some architecture in place for testing some hidden features (i.e. ab testing without the user interaction).

I though about using a parameter to select a specific view if it exists but fall back to the original otherwise.

This probably will work best if it also affects partials.

The idea is to route something like:

.../mycontroller/myview?hf=extra

to views/mycontroller/myview.hf_extra.html.erb if exists, otherwise views/mycontroller/myview.html.erb.

The same for all partials too.

This looks like defining an extra template handler,right? Does this make sense or should I attempt some different?

estani
  • 24,254
  • 2
  • 93
  • 76

1 Answers1

1

There are lots of different ways to accomplish this. If it's an entirely different layout/thing maybe something along the lines of this (from the rails guilds)

def show
  @book = Book.find(params[:id])
  if @book.special?
    render action: "special_show" and return
  end
  render action: "regular_show"
end
Gregory Ostermayr
  • 1,123
  • 10
  • 17
  • Yes, but he idea would be to not code this in every single method from every controller, but in a more general manner. Just like erb or html handlers are not coded in every method – estani Sep 04 '19 at 10:11
  • you may want to update your question to reflect that – Gregory Ostermayr Sep 04 '19 at 17:31