-
Notifications
You must be signed in to change notification settings - Fork 0
Models
Here are a list of relevant models, and a basic summation of what they do.
ItemTemplate-- It contains the general prompt for Questions, Challenges (now Solutions), and Events. Questions have many Solutions Questions have many Events item_id is SEPERATE from the question id (for example, Question 1 could be item id #4 if there are three events before the first question) so when you call the models Question, Challenge, Event, be aware they will auto join with the ItemTemplate table
All ItemTemplates have ResponseTemplates --which are the responses to a given item --they have a parent id, referring to the reply they are replying to --they have an item id, referring to the item thread they are discussing in.
==How to query this shit== Say, for example, we wanted to know all questions with a description that had the word "appcivist" in them. ItemTemplate.where(:description => "appcivist").where(:producible_type => "Question")
You have a given Response, and you want to find out what item type it belongs to. if the variable is stored in response, response.item_template.item_type (since the activerecord 3 relation is already in place, easy cheesy!)
--Categories--
-All ItemTemplates and Groups have categories --this is stored as a string in the database --but it ALSO is stored as a Category (for easy querying of data for popular cats, etc) --Categoryholder does this for item templates -UserCategory stores the preferences for categories for users and groups -So, if for example, you wanted all ItemTemplates with Category "dog", you'd do the following cat = Category.find_by_name("Dog") catHolders = Categoryholder.where(:category_id => cat.id)