railsでbitcoinを用いた送金アプリの作成
の環境構築
環境:
ubuntu16.04LTS
ruby2.3.1
rails4.2.7.1
openassets-ruby0.5.9
bitcoin0.13.01
Ruby,Railsインストール
Bitcoindインストール
http://techmedia-think.hatenablog.com/entry/2015/04/02/181014
開発用なのでbitcoin.confの中は
rpcuser=sample
rpcpassword=samplepass
txindex=1
server=1
daemon=1
testnet=3
rpcport=18332
と適当なユーザ名PWを書いて
テストネット3にして、ぽーとも18332に変える
OpenAssets-rubyのインストール
cd
git clone https://github.com/haw-itn/openassets-ruby.git
cd openassets-ruby
gem install bundler
(gemがなかったらこれを使う、sudo apt install bundleはダメ)
bundle install
Railsで動作確認
rails new sample
rails g scaffold Sample name:string
rails db:migrate
rails
さっきbitcoin.confで書いた名前とかをapp/controllerの中のsampleassets.rb(適当)に書いてbitcoin(rpcuser:sample rpcpw:samplepass rpcport18332)と同期させる
確認
rails s -b 0.0.0.0
(外部からみれる)
rails server
(localhostのみ)
でサーバ起動してみる
RailsのGemfileに追加を忘れずに
requireで見つからないよってエラー出たら
bundle list
gem list
とたたいてみると、さっき書いたbitcoinとかopenassets-rubyが、gem listにあってbundle listに入ってないのでGemfileに
gem 'bitcoin','バージョン'
gem 'open assets-ruby','バージョン'
をgem listを見ながら追加し
bundle update
gem update
もう一度サーバを起動してみると正常に接続できると思う
てことでrailsにopenassets-rubyを使えるようになった!