Please sign in to comment.
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...
Showing with 3 additions and 10 deletions.