jessedoyle / prawn-icon

Easy icons for Prawn.
Other
28 stars 15 forks source link

using with prawn-rails #31

Closed prees1 closed 6 years ago

prees1 commented 6 years ago

Do you know if prawn-icon works with this project?

It is complaining with: undefined method 'icon' for #<PrawnRails::Document:0x007fc353dc23c8> (NoMethodError)

Wondering if there is some other way I should be requiring it? I realize this isn't necessarily an issue that can be solved here. Just looking for help and wondering if its possible. Thanks!

jessedoyle commented 6 years ago

Hi @prees1 - thanks for using Prawn::Icon!

I haven't used prawn-rails before. I'll look into it and see if anything looks off. With that being said, as long as prawn/icon is required (by bundler or manually), there should be no issue using this gem.

While I look into it, would you mind sharing a small code snippet (just a minimal example is fine) that demonstrates the exception getting thrown?

Thanks!

jessedoyle commented 6 years ago

Hi @prees1 - I think I've got it figured out.

It looks like PrawnRails inherits from important Prawn classes. Because of this, the initialization prawn-icon performs here is lost.

If you add this line to config/initializers/prawn_rails.rb, you should be able to initialize prawn-icon with PrawnRails:

PrawnRails::Document.extensions << Prawn::Icon::Interface
PrawnRails.config do |config|
  # your configuration here
end

Please give that a shot and let me know if it works for you!

prees1 commented 6 years ago

That was it, works like a charm! Thanks @jessedoyle