Creating a helper instead of placing code in view

I have a form where a user can select a dropdown making it more user friendly. The Letters 'C','W', and 'R' are displayed as cycle, walk, & run The code is below:

= :kind, [['cycle','C'],['walk','W'],['run','R']]

How would I replace the code above and create a helper to do the same job



I see no benefit in having a helper that does not have more logic than the used select already handles. But I would move the nested array to the model that has this options. Than you have a reference in your model about valid options.

Assuming the model is named Exercise:

# in model
class Exercise
  KINDS = [['cycle','C'],['walk','W'],['run','R']]
  validate :kind, :inclusion => { :in => KINDS }

# in view
= :kind, Exercise::KINDS

Need Your Help

Linq search a list and a linked property

c# linq

I have a list of Books, each book has a linked Author. My Api allows a user to search either by Title or Author.

How do I start another activity when a button defined in main.xml is clicked

android button android-activity android-intent

I have two classes. One is Main and the other is HelloWorld. When I click a button which is defined in main.xml I want it to display a message defined in HelloWorld class to start. When i click the