0

I want to test out several landing page versions. Each version will have several variables such as:

@headline = "The Best App Ever"
@description = "Here's what the app does"
@hero_image = "hero.jpg"
@theme = "dark"

Ideally I would like to set only one variable in the controller, like:

@version = 1

And then in my view, I could call:

@version.hero_image

I'm sure this is really simple but I've never had to do it without actually creating a model and storing in the DB. Where should I store all these properties of each "version"?

1 Answer 1

1

You could define these as a series of hashes or json objects in an initializer that is referenced by a constant.

/initializers/homepage_versions.rb

HOMEPAGE_VERSIONS = [{:headline => xxxx, :description => xxxx}, {:headline => xxx}...etc]

Then in your controller just do something like @version = HOMEPAGE_VERSIONS[0]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.