Friday, November 4, 2011

[Rails] Validate in a model using a controller def

Hi

I hope someone can help me with this

I have a model Question, and its controller .. what I've done to
validate that there's no evaluation with 2 question with the same
number is

validates_uniqueness_of :qnumber, :scope
=> :evaluation_id

but when I try to update a question's content I got an error message
that says that "#{qnumber} has already been taken"
and that means that the validation works, but not as I want

Can I obtain wich "def" is using ? because I want to do this
- Question Model

IF ("def create" or something)
do the validation
elsif ("def update")
don't do it
end

I hope someone can help me

Thanks in advance

--
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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate