On Sun, Nov 6, 2011 at 00:10, JavierQQ
<jquarites-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote
(under former subject line "Re: [Rails] Re: Validate in a model using
a controller def", now overly polluted with off-topic junk):
>> 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.
>>
>> -Dave
>
> It works! ... well as far as I tested :), thanks a lot
You''re welcome, I''m glad it works. I haven''t
actually used something
like that, but the general technique of how I found it may be useful
to you: just take the important keywords, and Google them together.
IIRC, what I looked for was "rails validates uniqueness scope"
(without the quotes). What I suggested above was basically just
trying to cast your needs (as I understood them) into the syntax I
saw. Google-fu is a skill that will serve you well in many areas.
Another approach you might want to try is: make the question ordering
use drag and drop, with the user never seeing any question numbers.
Just apply the numbers yourself when the user wants to save the
evaluation. That will be a much more intuitive and less frustrating
user experience, especially on large evaluations so that you''d have to
renumber a lot of questions. That will also be a good way for you to
explore some great UI tricks you can use again later.
> I''ve been reading the messages about top-posting and I''m
really really
> sorry about any trouble I could have caused
Don''t worry, it wasn''t your fault.
-Dave
--
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.