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 This gives me exception And this error I expected since the usage of self Exception in Incident is undefined method `incident_id=' for IncidentCi:Class What I was trying to do the array iterates in that each sd ci information is there and get the required ones and copy that to corresponding incident cis and save But is there any other way to do this.Please help service_desk_cis table has the structure id integer | not null default nextval('service_desk_cis_id_seq'::regclass) service_desk_ticket_id | integer ci_id | integer | service_desk_ci_association_type_id | integer | modified_by | integer | created_on | timestamp without time zone | not null created_at | timestamp without time zone | not null updated_on | timestamp without time zone | not null updated_at | timestamp without time zone | not null incident_cis table has the structure id integer | not null default nextval('incident_cis_id_seq'::regclass) incident_id | integer | ci_id | integer | incident_ci_association_type_id | integer | modified_by | integer | created_on | timestamp without time zone | not null created_at | timestamp without time zone | not null updated_on | timestamp without time zone | not null updated_at | timestamp without time zone | not null Thanks in advance Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---