Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding docs for multiple counterCache #488

Merged
merged 1 commit into from Feb 20, 2013

Conversation

Projects
None yet
6 participants
Contributor

ankr commented Feb 17, 2013

No description provided.

Member

ceeram commented Feb 17, 2013

It is alreday mentioned in the possible keys section for belongsTo, but additional info never hurts. I would change the fieldnames to messages_read and messages_unread in the users table personally.

Contributor

ankr commented Feb 17, 2013

Oh right I see that now. Wouldn't it be easier to find if it's mentioned in the section for counterCache?
I can change the field names, no problem.

Member

ceeram commented Feb 17, 2013

yes, i think its helpfull to have it in the counterCache section as well.

Contributor

kimegede commented Feb 17, 2013

Squash both commits together?
And nice idea with adding it here too.

Member

ADmad commented Feb 17, 2013

I would rather have this info at one place instead of being split across 2 places on the same page.

Member

ceeram commented Feb 17, 2013

There already is 2 places, first is the association keys for belongsto,
second is the countercache section itself
Op 17 feb. 2013 22:49 schreef "ADmad" notifications@github.com het
volgende:

I would rather have this info at one place instead of being split across 2
places on the same page.


Reply to this email directly or view it on GitHubhttps://github.com/cakephp/docs/pull/488#issuecomment-13697571.

@markstory markstory commented on an outdated diff Feb 17, 2013

en/models/associations-linking-models-together.rst
@@ -540,6 +542,36 @@ Using our Image model example, we can specify it like so::
);
}
+**Multiple counterCache**
@markstory

markstory Feb 17, 2013

Owner

Why not use a proper title here?

@markstory markstory commented on the diff Feb 17, 2013

en/models/associations-linking-models-together.rst
+
+Since 2.0 CakePHP supports having multiple ``counterCache`` in a single model
+relation. It is also possible to define a ``counterScope`` for each ``counterCache``.
+Assuming you have a ``User`` model and a ``Message`` model and you want to be able
+to count the amount of read and unread messages for each user.
+
+========= ====================== ===========================================
+Model Field Description
+========= ====================== ===========================================
+User users.messages\_read Count read ``Message``
+--------- ---------------------- -------------------------------------------
+User users.messages\_unread Count unread ``Message``
+--------- ---------------------- -------------------------------------------
+Message messages.is\_read Determines if a ``Message`` is read or not.
+========= ====================== ===========================================
+
@markstory

markstory Feb 17, 2013

Owner

I think sphinx is not going to accept this table markup. The content of the cells overflows the separating whitespace. It may be the display on this phone as well though.

Contributor

ankr commented Feb 19, 2013

@ADmad What about I link to this new section from the belongsTo docs?
@markstory hmm, I think the table is correct, it works as expected when I make the html, ref: http://cakedocs.ankr.dk/build/html/en/models/associations-linking-models-together.html#multiple-countercache

  • And I've given both the new section and counterScope a "real" title each.
Owner

lorenzo commented Feb 19, 2013

@andreaskri there seems to be an old link in that page titled multiple-countercache can you please fix it and lin it to that section?

Owner

markstory commented Feb 19, 2013

@andreaskri Yeah the table is correct. The alignment issues were on my phone, sorry about that.

Contributor

ankr commented Feb 20, 2013

I removed duplicate info, added link from belongsTo => multiple counter cache and squashed the commits into one.

Member

ADmad commented Feb 20, 2013

@andreaskri I personally would rather have everything under the description for counterScope key where all belongsTo association keys are listed.

Owner

lorenzo commented Feb 20, 2013

@ADmad I think describing all keys makes sense, otherwise we would have to create separate sections for each of those to keep the style. This change looks good enough for me, we could look into cleaning up the section soon to avoid any duplication or long explanation for each key in the config arrays.

Owner

lorenzo commented Feb 20, 2013

@ADmad bah, never mind, I just realize you are for doing the opposite, having everything mixed in the same subsection with all the belongsTo keys

@lorenzo lorenzo added a commit that referenced this pull request Feb 20, 2013

@lorenzo lorenzo Merge pull request #488 from andreaskri/feature/multiple_countercache
Adding docs for multiple counterCache
e236e2d

@lorenzo lorenzo merged commit e236e2d into cakephp:master Feb 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment