heapsource / active_model_otp

Adds methods to set and authenticate against one time passwords (Two-Factor Authentication). Inspired in AM::SecurePassword
MIT License
773 stars 81 forks source link

undefined method `dark?' when creating QR-Code #61

Closed alliedarmour closed 5 years ago

alliedarmour commented 5 years ago

When i'm trying to get my QR-Code for the users to work I'm always getting this error message:

undefined method `dark?' for #

I'm not sure why this happens, I did everything like mentioned and in my controller I require the gem like: require 'rqrcode'

Then I'm trying to generate the QR-Code for 2-Factor-Authentication: @qr = RQRCode::QRCode.new(@user.provisioning_uri, :size => 8, :level => :h ) And in my view:

<table class="qr">
  <% @qr.modules.each_index do |x| %>
      <tr>
        <% @qr.modules.each_index do |y| %>
            <% if @qr.dark?(x,y) %>
                <td class="black">
            <% else %>
                <td class="white">
            <% end %>
        <% end %>
      </tr>
  <% end %>
</table>

Any suggestions?

davidnghk commented 4 years ago

Got the same error. No clue

catob commented 4 years ago

In case someone else struggles with this: https://github.com/heapsource/active_model_otp/wiki/Generate-QR-code-with-rqrcode-gem#create-the-qr-code