简体   繁体   中英

Simple error I think, but how can I require a gem installed file in one of my controllers? I get a LoadError

I installed the venice gem, which can be found here. https://github.com/nomad/venice

After installing the gemfile, it suggests using

require 'venice'

I have done this in my /api/v1/purchases_controller.rb class. Like this...

require 'venice'

class Api::V1::PurchasesController < ApplicationController

However, I end up getting the following error

FATAL -- : 
LoadError (cannot load such file -- venice):
  app/controllers/api/v1/purchases_controller.rb:1:in `<top (required)>'

Why is this. How can I use require this needed file in this one controller class (the only class I need it in).

In Rails applications gems are usually handled with Bundler .

Add the following line to your applications' Gemfile :

gem 'venice'

Then run bundle install in your console and restart your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM