railsアプリケーションをLAN内に公開する

普通にrails serverした場合、そのマシン上からしかアクセスできない
ちょっとスマホなど別の端末からみてみたい時に簡単にLAN内に公開する方法のメモ

オプション:binding

以下のように0.0.0.0を指定する

$ rails server --binding=0.0.0.0
=> Booting WEBrick
=> Rails 4.2.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server

同じLAN内の端末からRailsが起動している端末のローカルIPをポート番号とともに叩けば、アプリケーションへとアクセスできる

参考

Rails application not visible to local network
For the first time since upgrading to OSX Yosemite, I need to view an app running on my machine from another machine on ...

追記: Gem::GemNotFoundExceptionのエラーが発生

久しぶりに起動しようとしたところ、上記のエラーが発生し起動できなかった。
特に何かの変更を加えたわけではないはず…

調べてみるとstackoverflowにそれっぽいのがあったので、メモっておく。

以下のコマンドで解決。環境によっては、sudoが必要。

$ gem install bundler
$ bundle install

参考

Can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException)
I am trying to build a new application or check the version of rails. I get the following error: Traceback (most recent ...
タイトルとURLをコピーしました