I'm currently facing a bizarre issue. Here's how my view looks:
<h1>All Deals</h1>
<%= sanitize print_grouped_deals(@deals) %>
This is what's in my deals_helper.rb file:
def print_grouped_deals(grouped_deals_by_date)
grouped_deals_by_date.map do |(date, deals)|
%(<div id='#{date.to_s}-deals'>
<h3>#{brief_time date}</h3>
#{deal_paragraphs_for_group(deals)}</div>)
end.join
end
def deal_paragraphs_for_group(deals)
deals.map do |deal|
%(<p>#{"<span class='warning'>POSSIBLY EXPIRED! -</span>" if deal.probably_expired?} #{link_to deal.headline, deal}</p>)
end.join
end
Specifically, I'm having trouble with the third line in the first method of the second code snippet. I can't seem to get it to attach an id to my div tag! When I change
<div id='#{date.to_s}-deals'>
to <div class='#{date.to_s}-deals'>
, it adds the class without any issues. However, when I try to keep it as id=
, it just creates a plain <div>
tag without any attributes.
Just to rule out any issues related to generating multiple divs with unique ids, I also attempted to generate a simple <div id="thing" />
from the helper function, but still ended up with those empty div tags as the outcome.
What on earth is going wrong here?