Take the 2-minute tour ×

I'm new to rails and I guess you can answer this question easily.

What I got so far is

= f.input :task, :as => :select, :collection => @tasks, :include_blank => true

where the tasks collection is defined by


within in the controller.

This does in fact work, shows me a dropdown-list of all Tasks to select from and connects them. The problem here is, that the dropdown menu shows me values like


Where do I define what value is being displayed?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

I believe you can use the :label_method to solve your problem...

   :include_blank => true, :label_method => :title

where :title is what you want to show.

This may help a little more.

share|improve this answer
thank you very mouch, the link you posted worked great. Just had to implement a "to_label" function within the model class –  Infinite Aug 17 '10 at 19:09

You can define a to_s method in the model:

class Task < ActiveRecord::Base

  def to_s
    title # the attribute to display for the label

share|improve this answer

Your Answer


