Rather than putting your prompt text in the table, get rid of it, and
when you need to provide a drop-down for resolution code use the :prompt
argument to have rails insert the prompt for you. I believe that will
allow you to just put a "validates_presence_of :resolution_code" in
the
appropriate model & rails will "know" not to accept the prompt
value.
So your call to collection_select might look like:
<%= f.collection_select(:resolution_code,
ResolutionCode.find(:all),
:id,
:name,
{:prompt => ''Please select a
resolution''}
) %>
HTH,
-Roy
-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of
Sijo Kg
Sent: Thursday, May 15, 2008 12:24 AM
To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [Rails] validates_presence_of :if
Hi
I have a table service_desk_resolution_codes as below
id | name
----+------------------
1 | << Select Any >>
2 | Resolution 1
3 | Resolution 2
And I am using this to submit resolution code in select box in a
view.What i need is if the user select << Select Any >> a
validation
check is done says that this is not acceptable select any resolution
code..(Currently i have implemented it with a javascript).But how can i
do it in the model ServiceDeskResolution..Is the following way correct
validates_presence_of :service_desk_resolution_code_id, :if
=>"service_desk_resolution_code_id==1"
Surely this is error..But how can I do it in correct way
service_desk_resolution_code_id is a field of the table
service_desk_resolutions Thanks in advance Sijo
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---