fnando/page_meta

Error (undefined method `empty?' for #<Encoding:UTF-8>

Closed this issue · 2 comments

Hi,
I like the API offered by this Gem, unfortunately it doesn't work out of the box for a newly installed Rails (5.1.4) app.

I added <%= page_meta %> in the head of my application default layout, and translations for the current page title in the current locale, but got this error instead:

ActionView::Template::Error (undefined method `empty?' for #<Encoding:UTF-8>):

Any idea what causes this? I would have preferred sending a PR but I wasn't able to spot where the issue comes from.
Thanks!

Hey @goulvench or anyone else running into this.

I just used a monkey patch as a quick and dirty workaround. This gem is used by the https://github.com/fnando/coupons gem, and as I don't really care about the meta title of the coupons page, I just monkey patched it like this. This stops the error, but I haven't checked if it still shows the meta attributes appropriately as in my situation I don't care about them.

put this in
config/initilizers/page_meta_monkey_patch.rb

#https://github.com/fnando/page_meta/issues/3
module PageMeta
  class MetaTag
    class Charset < MetaTag
      def render
        return if content.blank?

        helpers.tag(:meta, charset: content)
      end
    end
  end
end

Closed via ae9b521..