On 14 September 2015 at 15:13, Luis <luismcdoug...@gmail.com> wrote:
> There is no unit test for this.

Then the solution is obvious.  Write one.

Colin

>
>
> On Friday, September 11, 2015 at 11:43:39 AM UTC-4, Luis wrote:
>>
>> Hi!
>>
>> I have the following classes  for  postgres rails 4 project :
>>
>> class Medhospital < ActiveRecord::Base
>>   belongs_to :pcp
>>   belongs_to :hospital
>>   validates_uniqueness_of :pcp_id, :scope => :hospital_id
>> end
>>
>> class Pcp < ActiveRecord::Base
>>     has_many :scheds
>>     has_many :medhospitals, dependent: :destroy
>>     has_many :hospitals, through: :medhospitals
>>     has_many :patients, through: :scheds
>>     accepts_nested_attributes_for :medhospitals, reject_if: :all_blank,
>> allow_destroy: true
>> end
>>
>> class Hospital < ActiveRecord::Base
>>     has_many :scheds
>>     has_many :medhospitals
>>     has_many :pcps, through: :medhospitals
>> end
>>
>> I am forcing the error to test and the validation for the uniqueness it is
>> not working instead I get this exception:
>> PG::UniqueViolation - ERROR:  duplicate key value violates unique
>> constraint "index_medhospitals_on_pcp_id_and_hospital_id"
>>
>> BTW I am testing manually  from a view form.
>>
>> Am I doing something wrong ?
>>
>> Thanks
>> -Luis
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/d98f5c78-ed3d-46f4-bcb2-451e4afc80de%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtKD4-P%3DiT3AA0GFV8Muo6%2BxmiapHygsKHXtiVLeMS_zQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to