Re: [Rails] Getting Acts_as_Paranoid to work with validates_uniqueness_of

Harvey Bernstein devlists-rubyonrails at devlists.com
Fri Mar 3 19:43:44 GMT 2006


Berin
Thanks for your help.  I was thinking about writing overriding the  
validate method and testing for the condition myself.  I'm not entirely  
sure if this is the best way to proceed?  So any help would be greatly  
appreciatd
Thank you

Regards
Harvey
On Thursday, March 02, 2006, at 3:14 PM, Berin Loritsch wrote:
>Harvey Bernstein wrote:
>> Hello
>> I've been using Acts_as_Parnoid for a while and it has been
>>working well
>> but I am now having a slight issue with it.  I have a company
>>table were
>> I would like to use  validates_uniqueness_of :company_name.  This
>> validation works if a company exists in the database and has not been
>> deleted.  However, I  also would like the validates_uniqueness_of to
>> work if a company has previously been deleted and has been flagged in
>> the deleted_at column.  Currently, if a company has been deleted, it is
>> possible to create another company with the same name.  I would like to
>> bring up a validation message to inform the user.  Is there an easy way
>> to accomplish this?
>>
>> Any help would be greatly appreciated.
>>
>
>Looking at the plugin code, you would have to specify the option
>:with_deleted => true to find companies that have been deleted.  The
>full list of options for find with this plugin is:
>
>[:conditions, :include, :joins, :limit, :offset, :order, :select,
>:readonly, :group, :from, :with_deleted]
>
>
>Not sure how validates_uniqueness_of works.  I'll look into that next.
>
>_______________________________________________
>Rails mailing list
>Rails at lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails





-- 
Posted with http://DevLists.com.  Sign up and save your time!


More information about the Rails mailing list