RSSAmplifier

HYBRD Posts · Oct 15, 2021

Active Record enum form select

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

I’ve been enjoying the new Active Record enums in Rails 4.1. But I haven’t found a nice way to represent the enum options in a form select. So, I wrote a couple small helper methods that I put in application_helper.rb: def options_from_enum_for_select ( instance , enum ) options_for_select ( enum_collection ( instance , enum ), instance . send ( enum )) end def enum_collection ( instance , enum )…

Read on hybrd.co

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.