Rails, React and me – codeburst

  • It uses rails to include only JS and Webpack compiled files which was perfect match for the use case.Figuring solutions is always easy, The difficult part is to figure out the problemReact_on_rails has given the instructions to setup existing rails project so I started with them but ran into many…
  • In this particular case, figuring out the problem became worse as the errors were misleading.The Aha Moment: Devil was in the detailsFinally to figure out the problem I created a sample project from scratch using react_on_rails new project setup instructions and started comparing the generated code with my existing project.
  • This particular information turned out to be crucial to get out of the problem I was facing which I was not aware of at that time.SolutionTo solve this issue just change your API controller to base controller.
  • Though I would suggest to convert your entire rails-5 api only app to normal rails app.
  • Once you have resolved everything run$bundle installThis will convert your rails-5 API only app to rails app which can easily be integrated with react_on_rails.

Integration of react and rails using react_on_rails gem in an existing rails-5 api only project

Rails, React and MeRails and React – two of very powerful frameworks when it comes to web development. Rails scaffolding and React components make development fast and integrating them in your web application is easy. There are three major ways to do that:react-rails gemreact-on-rails gemseparate rails API only app and react frontend appInitially — I took the third option but on realising that I should start with managing one stack instead of two. later decided to go with the second one. In this blog, I will talk about the major problems I faced while merging the two stacks. Along with this, I will also share some good lessons learnt during the entire process of finding out the problems and solving them.Why react-on-railsI needed an easy way to merge the two stacks without the need to rewrite the react files. React_on_rails allows you to use JSX components without changing them. You have a separate package.json for all your javascript dependencies which does not rely on rails pipelines at all. It uses rails to include only JS and Webpack compiled files which was perfect match for the use case.Figuring solutions is always easy, The difficult part is to figure out the problemReact_on_rails has given the instructions to setup existing rails project so I started with them but ran into many problems as those instructions were not considering the Rails-5 API only projects. When you add react_on_rails and start with it. It gives an error of missing layout as shown in the image.Layout errorTo resolve this,…

Rails, React and me – codeburst