2009/9/28 RVince <[email protected]>:
>
> How do I amend the form helper:
>
> <%= select("lead", "associate_id", Associate.all.collect {|p|
> [ p.to_s, p.id ] }, {:include_blank => ''}) %>
>
> (which is magnificently SIMPLE, and I don't want to convolute it here,
> which is why I am asking the experts on this list...)
>
> To NOT display records where Associate.deleted != 0 ?
You could provide a named scope of Associate that finds records where
deleted != 0 (called active or whatever is right for you) then use
Associate.active instead of Associate.all.
In fact I would also provide a method of Associate that returns the
collected data, then it becomes even simpler
<%= select("lead", "associate_id", Associate.options_for_select,
{:include_blank => ''}) %>
This also makes testing simpler as you can test options_for_select in
a unit test.
>
> Additionally, how would I amend it if I have and Associate.id that I
> want to be selected in it? Thanks guys.
Sorry I don't understand the question
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---