id integer not null default
nextval('public.service_desk_tickets_id_seq':
:text)
number character varying(15)
title character varying(100)
service_desk_status_id integer
etc.....
2)cis
id integer not null default nextval('public.cis_id_seq'::text)
citype character varying(30)
ci_number character varying(15)
content_id integer
etc....
3)service_desk_cis(This is a junction table)
id integer not null default nextval('public.service_desk_cis_id_se
q'::text)
service_desk_ticket_id integer
ci_id integer
service_desk_ci_association_type_id integer
The implementation of has_many and belongs_to association is only not enough to join two taIf u have implement two tables…And also u use the following query
@sd_cis=ServiceDeskTicket.find(params[:id], :include [:service_desk_cis])
and u retrieve the field of ServiceDeskTicket table as
@sd_cis.id
and u retrieve the field of Service_desk_cis table as
@sd_cis.service_desk_cis.service_desk_ci_association_type_id
If I comment last line(@sd_cis[loop_index.....)No error everything
ok.But if uncomment it I get the error
undefined method `service_desk_ci_association_type_id' for
ServiceDeskCi:Class
def self.down
drop_table :service_desk_tickets
end
end
In the controller
@sd_ticket=ServiceDeskTicket.find(params[:id])
@sd_ticket.service_desk_cis.each do |t|
puts t.service_desk_ci_association_type_id
end
I need to know what it works or no. if it is not working, it means that
your cis can not be linked to service_desk_cis, so you can try to add
foreign key there.