Append Options to a Select field in Ruby on Rails

Posted on

Have you ever needed to add some options to a select field in ruby on rails but didn’t know how? I did – and when I googled it, I didn’t find much help. After a bit of research, it occurred to me that its actually very simple.

I use two helpers that both generate a string with the options rendered in html. Then I just concatenate them together and pass them to the f.select form field helper for rails.

Let me know if this helped you out. Thanks for reading.