Trouble including httparty in ruby on rails

前端 未结 6 1564
迷失自我
迷失自我 2021-02-18 23:16

I\'ve been trying to use HTTParty in my rails code

sudo gem install httparty

From the command line I can now successfully do

ht         


        
6条回答
  •  长发绾君心
    2021-02-19 00:14

    You don't need to do 'include HTTParty' inside the Controller. Just remove that and it should work. I just tested it and it worked for me. If this doesn't work for you, you should add the gem to your environment.

    Usually if you use a gem inside your Rails application, you should add the following to environment.rb:

    config.gem "httparty"
    

    The gem will be available in the application now and you don't need to add 'require' inside the Controller. Also, you don't need to require RubyGems inside a Controller.

    When you use Rails 3, you need to put the following inside the Gemfile:

    gem "httparty"
    

    I hope it works for you. :)

提交回复
热议问题