How to use react on rails


Omakase

http://david.heinemeierhansson.com/2012/rails-is-omakase.html

5 different ways to use react on rails

1. Using only Rails 5 webpack methods
2. Using react_on_rails
3. Using rails-api mode and react separately

1. Using only Rails 5 webpack methods

  1. Create a new rails app with this command
    rails new lyntour --webpack=react --database=postgresql -T --skip-coffee --skip-sprockets
    

2. Using react_on_rails gem

  1. create a new rails app with this command
    rails new lyntour --webpack=react --database=postgresql -T
    
  2. install react_on_rails and install
    rails generate react_on_rails:install
    bundle && yarn
    

3. Using rails-api mode and react separately

  1. Create a new rails app in api mode
    rails new _5.1.5_ lyntour --api --database=postgresql -T
    

References