On Sep 26, 7:28 am, Sijo Kg <[EMAIL PROTECTED]> wrote:
> Hi
> I have to copy all the service desk cis to incident cis as part of
> converting sd_ticket to incident..So in the Incident model I did
> sd_ticket=ServiceDeskTicket.find(sd_id)
> Then a new incident @incident is created here
> sd_cis=sd_ticket.get_sd_cis #here I got all the service desk cis
> (Relation is ServiceDeskTicket has_many ServiceDeskCis
> @incident.incident_cis.add_incident_cis(sd_cis) unless sd_cis.size == 0
> #here what I am trying is to add all the sd_cis to incident_cis table
>
> So in IncidentCi class
> def self.add_incident_cis(cis_array)
> cis_array.each do |ci|
> #puts 'In Incidentci cis are : '+ci.ci_id.to_s
> self.incident_id=self.id
> self.ci_id=ci.ci_id
> #then tries to save record
> end
> end
You should be creating a new instance of IncidentCi and setting values
on that (and the values should be coming from ci).
self shouldn't be used in that way at all in this method - it's just
nonsensical.
Fred
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---