Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the Article#to_indexed_json to include data from associations
In the published version, special methods `Article#author_name` and `Article#comments_count` were added, so we can display some data about authorship and comments from associations. This would be less then ideal in a bigger codebase, and, moreover, Elasticsearch & Tire make it trivial to support this use case. The only thing we need to do is to `include` the selected information from the associated models in the `Article#to_indexed_json` declaration. In this way, the information about: * Name of the article author * Name of commenters and bodies of their comments is included in the index. This has two benefits: 1. It's **searchable**! :) We can search within the comments in the same way as we do within articles. 2. We don't have to add special methods, and can revert the HTML layer to the original state.
- Loading branch information
ee1f6f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would there be any changes to the "mapping" area?... can we still use author_name, comments_count there?
ee1f6f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, no, this must be changed: see subsequent commit 03c45c3.