Prefix a drop-down with "Select Item" -- Rails way?

Hi,

I'm finally a happy developer of a Rails app that's got a working drop-
down. In short, I prefixed the array of Vendors (which all have
integer IDs > 0) with an new Vendor with in ID of 0 and a string
"Select ..." in the field that populates the drop down. I'll use some
kind of "before" command to report "selection req'd" if no valid
selection had been made upon creating/saving/whatever.

The code below works. Is there a better "Rails way"?

Thanks in Advance,
Richard

    <%= f.label :vendor %><br />
    <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%>
    <% @v = Vendor.new; @v.id=0; @v.nickname = "--Select Vendor--" -%>
    <% @vendors.insert(0, @v) -%>
    <%= f.collection_select(:vendor_id, @vendors, :id, :nickname) %>

+another. I would suggest that RichardOnRails brush up on MVC.

-Dave

I would suggest that RichardOnRails brush up on MVC.

Why don't you say explicitly how I can avoid offending your
sensibility about MVC?

I know of no threshold of Rails expertise before posting questions on
this newsgroup.

I suspect that people with high levels of Rails respond to a question
like mine:
- in order to enlarge the "Rails community"
- for: the joy of helping their fellow humans
- with the expectation the their responses will bring the consulting
opportunities
- or heap scorn on those whom they perceive as inferior

I'll check back later on this thread.
Richard

I know of no threshold of Rails expertise before posting questions on
this newsgroup.

Nope, nor even for posting answers, as I amply demonstrate. <:-)

I suspect that people with high levels of Rails respond to a question
like mine:
- in order to enlarge the "Rails community"
- for: the joy of helping their fellow humans
- with the expectation the their responses will bring the consulting
opportunities
- or heap scorn on those whom they perceive as inferior

I think you have read more into my post, than I intended. I certainly
did not mean to heap scorn on you, only to help you realize what
specific concept you seem to be failing to understand. Putting a name
on it helps you find information about it. You seem to be in need of
brushing up on MVC because you're putting controller logic in your
view, and apparently some people have corrected you on this
(anti-)pattern several previous times. (Unfortunately, controller and
view are not like chocolate and peanut butter....)

Peace? Joy? Consultancy? :wink:

-Dave

Thank you, my knight in shining armor! :wink:

-Simon des Beaux Eaux, NAS, mka Dave

Hey Dave,

I was "baby sitting" my 14-yo granddaughter for a week, so that kept
me away from my project. Thinking about my project during some idle
time today, I realized I should put my setup-code in the Vendor-
controller. As I was about to that, I reread your post to and
discovered you had provided an answer buried in a lot of distracting
verbiage:

you're putting controller logic in your view

That's the simple and direct answer to my question. I appreciate you
providing it and wish that it had been provided as the first line of
your response. Nevertheless, thank you for confirming what I thought
about today.

Best wishes,
Richard