docs/oss/misc/doctrine.md
By Justin Gordon, January 26, 2016
This document is an extension and complement to The Rails Doctrine. If you haven't read that document, I suggest you do so first.
To paraphrase the React on Rails Introduction, the project objective is to provide an opinionated and optimal framework for integrating Ruby on Rails with modern JavaScript tooling and libraries.
When considering what goes into react_on_rails, we ask ourselves, is the functionality related to the intersection of using Rails and with modern JavaScript? A good example is view helper integration of React components on a Rails view. If the answer is yes, then the functionality belongs right here.
In other cases, we release separate npm packages or Ruby gems. For example, we needed an easy way to integrate Twitter Bootstrap with Webpack, and we released the npm bootstrap-loader.
Besides the project objective, let's stick with the "Rails Doctrine" and keep the following in mind.
The React on Rails setup provides several key components related to front-end developer happiness:
/client directory, pure JavaScript developers can productively do development separate from Rails. Instead of Rails APIs, stub APIs on an express server can provide a simple backend, allowing for rapid iteration of UI prototypes.We're big believers in this quote from the Rails Doctrine:
The same goes even when you understand how all the pieces go together. When there’s an obvious next step for every change, we can scoot through the many parts of an application that is the same or very similar to all the other applications that went before it. A place for everything and everything in its place. Constraints liberate even the most able minds.
Here's the chef's selection from the React on Rails community:
By having a common set of tools, we can discuss what we should or shouldn't be using. Thus, this takes out the "JavaScript Fatigue" from having too many unclear choices in the JavaScript world.
By the way, we're not omakase for standard Rails. That would be CoffeeScript. However, the Rails Doctrine makes it clear that non-standard menu choices are certainly welcome!
React on Rails fits into the "No One Paradigm" of the Rails ecosystem from the perspective that it rocks for client-side development with Rails, even though it's a totally different language than the server code written in Ruby.
ES5 was ugly. ES6 is beautiful. React is beautiful. Client side code written with React plus Redux, fully linted with the ShakaCode linters, and organized per our recommended project structure is beautiful. Don't take our word for it. Take a look at the component sample code in the react-webpack-rails-tutorial sample code.
Assuming that you're building the type of app that's a good fit for Rails (document/database based with lots of business rules), the tight integration of modern JavaScript with React on top of Ruby on Rails is better than building a pure client-side app and separate microservices. Here's why:
React on Rails will maintain an active pace of development, to keep up with:
React on Rails is definitely a part of the big tent of Rails. Plus, React on Rails provides its own big tent. A huge benefit of the React on Rails system is simple integration with Webpack and NPM, allowing integration with almost any library available on npm! The integration with Webpack also allows for other Webpack supported build tools.
Thanks for reading and being a part of the React on Rails community. Feedback on this document and anything in React on Rails is welcome. Please open an issue or a pull request. If you'd like to join our private Slack channel, please email us a request.