I am having trouble limiting the matches for elements in a Section I'm writing. See the example HTML and Comment Section below.
I want to be able to reply to a specific comment on the page. Comments can be nested up to X deep. I can use all_comments and iterate through them to find the matching:body text and then use that Comment's:reply_button to reply to it.
However, for comment with replies, body, reply_button give AmbiguousMatches, because there are multiple children of the current section/Comment that match the given classes (the duplicates coming from nested replies).
I'm trying to work out how to specify a selector in SitePrism that will exclude anything under the replies div, or in some other way only match the elements for THIS comment, not any of its replies.
I managed to beat it into submission in a horrible way, by defining the elements as 'elements' (plural), and then always take the first one of the list (which is the relevant one for this Comment), I've done that with accessor methods (for each of the elements/sections on the Comment), but it feels terribly messy.
Hope this makes some sort of sense!
<div class='comment'>
<div class='commentText'>
<div class='replyButton'>
<div class='replies'>
<div class='comment'>
<div class='commentText'>
<div class='replyButton'>
<div class='replies'>
class Comment < SitePrism::Section
element :body, '.commentText'
element :reply_button, '.replyButton'
sections :all_comments, Comment, '.comment'