Yeah, Sorry, I also have a Knowledge and Skills table which i forgot to add to my initial post. And yes, prior is the same as required.
I think what Colin suggested about using a boolean may actually work quite well. The problem i was having using the :through was that in writing, "has_many knowledges, :through prior_knowledges", i would also have, "has_many knowledges, :through enabled_knowledges". But using a boolean should solve that problem. Thanks very much for your suggestions, and sorry about my convoluted explanations. Colin Law wrote: > On 13 July 2010 06:03, Adrian Zatta <[email protected]> wrote: >> Hi everyone, >> I have the following basic rules: >> �Subject has many elements >> �Element has many subjects >> �Element has many knowledges which are either enabled or required >> �Element has many skills which are either enabled or required >> >> I have designed the schema to have 6 tables, Subjects, Elements, >> PriorKnowledge, PriorSkills, EnabledKnowledge and EnabledSkills. > > You talked about required earlier, is that the same as prior? > > Is there a good reason why you don't just put PriorKnowledge and > EnabledKnowledge in the same class and table with a boolean to > indicate which? > >> >> Now to my problem. I am trying to build a page that will display all >> this information. It will display a subject and all its elements, and >> all of the elements prior and enabled, knowledges and skills. >> >> The thought that I had was to use has_many :through relationships, but I >> don't know how to handle both prior and enabled cases. > > I am obviously missing something, why can't you just say > @element.prior_knowledge > and > @element.enabled_logic > >> >> My next thought was to use a sql query to select the knowledge and skill >> elements required and save them as class variables in elements. However >> I don't know how to get the ID of the element i am working with. >> >> This is the SQL query that does the job: >> � � � select description from knowledges where id in (select >> knowledges_id from prior_knowledges where elements_id = 1); > > Now you seem to have a 'knowledges' table which you have not mentioned > before. > > Colin -- 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 [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.

