开发者

RQRcode error for Ruby on Rails

I'm getting the following error 开发者_如何学运维from Ruby on Rails in my EquipmentController#show

uninitialized constant EquipmentController::RQRCode

controller

 def show  

    @equipment = Equipment.find(params[:id])
    @equipment_statuses = EquipmentStatus.all      
    @equipment_bookings = EquipmentBooking.find_all_by_equipment_id(params[:id]) 

    @qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )

    respond_to do |format|
      format.html # show.html.erb     
      format.json { render json: @equipment }
    end
  end

view -- show

<div class="qr">
        <table>
        <% @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>
  </div>

gemfile

gem 'rqrcode-rails3'

I'm running Rails 3.1.0

Any ideas what the problem might be?


I think your code needs

require 'rqrcode'

in your environment.rb or your controller


I think this is one of those 'restart your server' moments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜