xvidun
xvidun

Reputation: 477

Accessing gem functions from controller in rails

I have a bitcoin-ruby in gemfile, how do I access the following from my rails controller?

key = Bitcoin::generate_key
@address = Bitcoin::pubkey_to_address(key[1])

Error:

uninitialized constant HomeController::Bitcoin

Gemfile:

gem "bitcoin-ruby", "~> 0.0.4"

I tried to do this in plain ruby, (installing bitcoin-ruby was successful)

require 'bitcoin-ruby'

Throws up the following error.

/home/p4/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- bitcoin-ruby (LoadError)
from /home/p4/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from bitcoin.rb:2:in `<main>'

Probably it is due to my lack of understanding of linking ruby libraries, where am I wrong?

Upvotes: 0

Views: 174

Answers (1)

Ernest
Ernest

Reputation: 8829

According to the README you need to add a require key:

gem "bitcoin-ruby", "~> 0.0.4", require: 'bitcoin'

Upvotes: 2

Related Questions