Ask A Question

Notifications

You’re not receiving notifications from this thread.

Is it possible to incorporate React + Redux into existing Rails application?

Ken Hibino asked in Javascript

I have been working on creating a Medium clone to learn Ruby on Rails. It started out as just a plain Rails app but as the app evolved I started using React in the front end (using react-rails gem). The "react-rails" gem is great, and I was really happy with the gem in the beginning. But then I learned about Redux and learned how to use it with React and I think it's a great solution for managing application level states. I'd love to use Redux in my Rails app but haven't found any good solution to incorporating it with react-rails gem. ( I found "react-on-rails" gem but it seems very heavy and I want to keep the app light weight as much as possible) Do you know any good solution to this? Here's the URL for the app, and Github repo :)
app: http://my-medium-clone.herokuapp.com/
github: https://github.com/kenny-hibino/stories

Reply

Ken, this looks amazing. I hope you keep it open source, a lot of us can learn a ton from it. How long have you been using rails?

Reply

Thanks Szilard! I'm planning on keeping this open source so that people can take a look at the code and also make pull requests if they want to. I started learning Ruby on Rails in September and have been making apps to practice what I've learned from books and videos. Feel free to contribute, it's a fun side project to work on :)

Let me know if anyone knows how to integrate React + Redux into Rails application :)

Reply

Ken what were you doing before you started learning Rails? This site packs some massive features. You must be dedicating a lot of time to learn so much so quickly :)

I was writing some code last night and saw your post just before I was about to go to bed. Ended up watching your videos for another hour hah.

Reply

Thanks Jay :) I'm a CS student so I had been writing lot of Python code for school projects before I started learning Rails. I also learned AngularJS(1.x) during the summer break so that experience helped me with learning Rails as well. But I especially loved Rails and went through a bunch of tutorials, watched lots of screencasts and read quite a few books on the subject.
And thanks for watching the videos, it's not as good as Chris's but I'm trying to share what I've learned so far and showcase the project I've been working on with the community.

Reply

I really appreciate being able to watch the process you go through. The hardest part I have found in learning rails is incorporating TDD/BDD and I was happy to see you step through that with each of your features.

Very jealous by the way that you have all this time to learn it all as part of your studies. I'm self taught so have to fit everything in between my day job and social life. CS students must have very high pass rates to be able to work on such rewarding projects :)

Sorry for the questions, not really helping with your problem but just curious about the journey you've been on.

Reply

I'm happy to hear that Jay :) Just an an FYI, I learned a lot of TDD/BDD from Thoughtbot's screencasts (the website is called "Upcase") and book called "Rails 4 Test Prescriptions."

Reply

Ken - Your project looks great; I'll definitely follow along and maybe get involved when I come up for air! I think you should be able to incorporate Redux with an approach like this: https://reactjsnews.com/setting-up-rails-for-react-and-jest. If you use browserify, then I think you could include Redux (and any other js module) in the same manner that this article describes for including Jest. I played with this approach (not Redux, but using react and Reflux and ImmutableJS) last year and it worked. I'm about a month away from having to do this again in production. I'm not sure whether I'll follow this approach again or just bite the bullet and try react_on_rails. I'll definitely be interested in what you think/how you approach, so keep us posted!

On a separate but related note, I highly recommend Stephen Grider's two classes on Udemy -- "Modern React with Redux" and "Advanced React and Redux". They don't involve rails, but he does a great job teaching react and redux.

Reply

Thanks for the reply Patrick! I will definitely check out the article and try using browserify_rails in my Rails app. If I was creating a new Rails app, I will consider using react_on_rails gem but mixing the gem into an existing Rails app seems a bit too difficult. But this approach sounds promising, hope it works nicely with Redux too. I'll definitely keep you posted here in this thread. And it'd be really really awesome if you can get involved in this project :)

I've taken the first Udemy course "Modern React with Redux" and I learned a lot from the course. I didn't know an advanced course came out. Thanks for letting me know!

Reply

Hi Ken,
I just took a look at your medium clone. Wow, looks really good! Thanks for sharing your journey and code on github. I've been messing around with React and really enjoy it.

Reply

I've been using ReactJS and Redux with a JS stack, MERN. MongoDB, Express, React, NodeJS but would love to see a series, tutorial using Ruby, maybe the Rails API gem or Grape.

This is cool, thanks so much for sharing

Reply

Hey Ken,

I was searching gorails for Redux content and went to check out your application and it looks like its down? Is this still an active project?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.