Banners created through the admin form were getting the default color. However, banners created by other means (like the `db:dev_seed` rake task) were not getting these default values. This feature was originally implemented when we were using Rails 4. With Rails 5, we can provide default values to all new banners and simplify the code at the same time thanks to its `attribute` method. Now, when creating a new banner, instead of getting a blank space, we get an empty line with the banner's default background color, which most users won't know what it's about until they fill in the banner's title. So we're not displaying the content of the banner when it's empty, thanks to the `:empty` CSS pseudoclass.
13 lines
313 B
Ruby
13 lines
313 B
Ruby
module BannersHelper
|
|
def has_banners?
|
|
@banners.present? && @banners.count > 0
|
|
end
|
|
|
|
def banner_target_link(banner)
|
|
link_to banner.target_url do
|
|
tag.h2(banner.title, style: "color:#{banner.font_color}") +
|
|
tag.h3(banner.description, style: "color:#{banner.font_color}")
|
|
end
|
|
end
|
|
end
|