«

Simpleform Input Field Without a Model

For a recent project, I wanted to use the Rails Gem SimpleForm to create a select element without a backing model. It seems like this is a common use case, but since it’s not defined anywhere in the documentation, I thought I’d note it here.

In case anyone else runs into this, this is how to create a dropdown that contains “Black” and “Yellow” in SimpleForm without a model

<%= f.input :favorite_color,
            label: "Favorite Color",
            collection: ["Black","Yellow"],
            selected: "Yellow" %>

Boom. Problem solved.

Simpleform Input without backing model

Share Comment on Twitter