Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Use Rails Console Via Jupyter

I want to use Jupyter notebooks as my rails console, exactly like django-extensions allows via shell_plus --notebook in Django.

Any ideas how to do this?

I saw this post which seems to be explaining how to do what I want, but I don't read Japanese or really understand whats going on here.

like image 755
rump roast Avatar asked Mar 30 '16 18:03

rump roast


2 Answers

Require config/boot, config/application then call Rails.application.require_environment! method.

require 'RAILS_ROOT_PATH/config/boot'
require 'RAILS_ROOT_PATH/config/application'
Rails.application.require_environment!
like image 91
codebicycle Avatar answered Oct 04 '22 18:10

codebicycle


Today I made a gem to automatically do the things needed for running rails c on juyter.

https://github.com/Yuki-Inoue/jupyter_on_rails

You add

gem 'jupyter_on_rails'
gem 'ffi-rzmq'

to your Gemfile, bundle install, and execute

rake jupyter:notebook

The opened jupyter should have a kernel named to your Rails app, and it'll automatically load the Rails app on initialization.

like image 32
Yuki Inoue Avatar answered Oct 04 '22 18:10

Yuki Inoue