Thanks for your reply and sorry for my late response =)
I'm using Typus, I know that theres a group for typus but I think that
this problem can happen everywhere
> You are still being too vague about your requirement, for me anyway.
> Can you write the validation test as pseudo code, being absolutely
> clear about each reference there? Ignore everything about the meaning
> of the database fields and just write the validation requirement in
> terms of data in the database and the new data about to be saved,
> referencing just database fields.
>
I have a view of evaluations
EVALUATIONS
Name View questions Add question
Math view add (edit)
Science view add (edit)
EVALUATION : Math
QUESTIONS
Number View alternatives Add alt.
1 view add (edit)
2 view add (edit)
3 view add (edit)
with
validates_uniqueness_of :qnumber, :scope => :evaluation_id
I made that there's only one question number "1" on each evaluation
the only problem that I have (as I mentioned before) is that, when I
edit the second question (# 2)
and I change its content, it doesn't let me to do it, because they
found that the number (# 2) has been already taken
The other problem is what happens if I want to edit
the second question (# 2) and I change the number to (# 3)
with that validation it let me do that, but what if I edit the second
question (#2)
and I put (#1).... there will be two questions with the same number
(#1)
I was searching for a validation for it, I've been reading the
validation guide and found section 15 about
Proc.new.... it could help but I don't understand it well (I'm really
new with rails)
> JavierQQ, try this:
>
> validates :qnumber, :uniqueness => { :scope => :evaluation_id,
> :message => "must be unique within each evaluation" }
>
> in the model, and let us know what happens. Don't worry about what
> controller it's going through to get there.
s>
> -Dave
It works! ... well as far as I tested :), thanks a lot
I've been reading the messages about top-posting and I'm really really
sorry about any trouble I could have caused
Thanks a lot Colin for keep on trying to help me, I'll follow your
advice about how to post something
--
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.