Hi
The following is one solution I got to my problem
class KnowledgeBase < ActiveRecord::Base
has_many :sd_knowledge_bases
has_many :sds, :through => :sd_knowledge_bases
# (...)
end
app/models/sd.rb
class Sd < ActiveRecord::Base
has_many :sd_knowledge_bases
has_many :knowledge_bases, :through => :sd_knowledge_bases
# (…)
end
app/models/sd_knowledge_base.rb
class SdKnowledgeBase < ActiveRecord::Base
belongs_to :knowledge_base
belongs_to :sd
# (...)
end
in controller action (assuming params[:id] is the ID of your SD)
@knowledge_bases = Sd.find(params[:id]).knowledge_bases
But I get the error
uninitialized constant SD::SDKnowledgeBasis
Note Basis
My table structure as below
1)knowledge_bases
id integer not null default
nextval(‘public.knowledge_bases_id_seq’::text)
name character varying(200)
keyword text
url character varying(500)
summary text
details text
2)sd_knowledge_bases
id integer not null default
nextval('public.service_desk_knowledge_bases_id_seq
'::text)
sd_id integer
knowledge_base_id integer
Pls help
Sijo