Re: ROR + React

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Joe Guerra
I guess this is what I'm looking for?

https://github.com/reactjs/react-rails

On Monday, August 19, 2019 at 2:48:03 PM UTC-4, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Stephen-50
You likely just want —webpack=react if using rails 5.1 or higher
Sent from my iPhone

On Aug 19, 2019, at 2:54 PM, Joe Guerra <[hidden email]> wrote:

I guess this is what I'm looking for?

https://github.com/reactjs/react-rails

On Monday, August 19, 2019 at 2:48:03 PM UTC-4, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5D84E079-A6D6-4778-8769-E4E329A50263%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Joe Guerra
Thanks.

Can I add react to my existing project or should I start over?

On Monday, August 19, 2019 at 3:14:36 PM UTC-4, Stephen Blackstone wrote:
You likely just want —webpack=react if using rails 5.1 or higher
Sent from my iPhone

On Aug 19, 2019, at 2:54 PM, Joe Guerra <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="JVxwVuf6AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">JGu...@...> wrote:

I guess this is what I'm looking for?

<a href="https://github.com/reactjs/react-rails" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Freactjs%2Freact-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFCYtdSOCICrwfzgWrpaP98DqLdSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Freactjs%2Freact-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFCYtdSOCICrwfzgWrpaP98DqLdSg&#39;;return true;">https://github.com/reactjs/react-rails

On Monday, August 19, 2019 at 2:48:03 PM UTC-4, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="JVxwVuf6AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/aba8b4ba-eefb-45f9-8fd8-c4243a36079a%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Noel
In reply to this post by Stephen-50
    There are at least 4 different ways that I'm familiar with and tons of resources to help you execute the way that works best for you. Here's the ones I've learned from researching:

1. Approach 1 - CDN based inclusion in header

- You can include it just as a link on the html pages you want to include some React functionality. This is as simple as putting it in the header of the pages.

2. Approach 2 - React Front-end/Rails API backend (pre-existing app)

- Convert controllers into API folders with namespacing technique and create the front-end `client` as shown in Approach 3.

3. Approach 3 - React Front-end/Rails API backend

- This approach works by creating a rails api
rails new myapp --api

- Within the directory of the app run
create-react-app client

- Install foreman gem, create Procfile with the following:
RAILS: bundle exec rails s -p 3001
REACT
: cd client && npm start
 (caveat: If deployed on Heroku, you may need to change `REACT` to `web`.)

- Run servers by
foreman start

- You will need something like axios in node to make the front-end `client` talk to the rails backend but this works.

4. Approach 4 -React-rails gem install
- This approach, I cannot speak to because it seemed the most .... coupled. In the back of my mind, I tend to think this couples react to rails in a way I, at this level of my knowledge, would not be able to decouple if I were to revert to something else or use Vue or stick to normal html requests.

Forgive me giving my opinion on that last one, if someone has more insight on the gem approach, I'd be happy to hear it.



On Monday, August 19, 2019 at 2:14:36 PM UTC-5, Stephen Blackstone wrote:
You likely just want —webpack=react if using rails 5.1 or higher
Sent from my iPhone

On Aug 19, 2019, at 2:54 PM, Joe Guerra <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="JVxwVuf6AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">JGu...@...> wrote:

I guess this is what I'm looking for?

<a href="https://github.com/reactjs/react-rails" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Freactjs%2Freact-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFCYtdSOCICrwfzgWrpaP98DqLdSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Freactjs%2Freact-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFCYtdSOCICrwfzgWrpaP98DqLdSg&#39;;return true;">https://github.com/reactjs/react-rails

On Monday, August 19, 2019 at 2:48:03 PM UTC-4, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="JVxwVuf6AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/774f99b0-1647-432f-855b-3d0079ab15ff%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Jason Fleetwood-Boldt



Another approach is simply to have two completely separate apps: A REACT JS app deployed on Express (google "Create React App on Express") and a separate Rails app, deployed separate to separate servers (/dynos). (It's two separate apps!)

It's not a matter of "Can Rails serve up a React app via the asset pipeline (5.1/5.2) or webpack (6+)?" -- of course it can -- the answer is yes— but should you? 

These days I build out two separate apps even (a React front-end and a Rails backend) even when starting from scratch and even knowing that webpack is default in Rails 6 and that Rails is perfectly capable of serving up the React front-end. 






On Aug 19, 2019, at 3:29 PM, Noel <[hidden email]> wrote:

    There are at least 4 different ways that I'm familiar with and tons of resources to help you execute the way that works best for you. Here's the ones I've learned from researching:

1. Approach 1 - CDN based inclusion in header

- You can include it just as a link on the html pages you want to include some React functionality. This is as simple as putting it in the header of the pages.

2. Approach 2 - React Front-end/Rails API backend (pre-existing app)

- Convert controllers into API folders with namespacing technique and create the front-end `client` as shown in Approach 3.

3. Approach 3 - React Front-end/Rails API backend

- This approach works by creating a rails api
rails new myapp --api

- Within the directory of the app run
create-react-app client

- Install foreman gem, create Procfile with the following:
RAILS: bundle exec rails s -p 3001
REACT
: cd client && npm start
 (caveat: If deployed on Heroku, you may need to change `REACT` to `web`.)

- Run servers by
foreman start

- You will need something like axios in node to make the front-end `client` talk to the rails backend but this works.

4. Approach 4 -React-rails gem install
- This approach, I cannot speak to because it seemed the most .... coupled. In the back of my mind, I tend to think this couples react to rails in a way I, at this level of my knowledge, would not be able to decouple if I were to revert to something else or use Vue or stick to normal html requests.

Forgive me giving my opinion on that last one, if someone has more insight on the gem approach, I'd be happy to hear it.



On Monday, August 19, 2019 at 2:14:36 PM UTC-5, Stephen Blackstone wrote:
You likely just want —webpack=react if using rails 5.1 or higher
Sent from my iPhone

On Aug 19, 2019, at 2:54 PM, Joe Guerra <[hidden email]> wrote:

I guess this is what I'm looking for?

https://github.com/reactjs/react-rails

On Monday, August 19, 2019 at 2:48:03 PM UTC-4, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e66ae529-9607-4952-9798-cc229591f9bd%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/774f99b0-1647-432f-855b-3d0079ab15ff%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4D000714-22D3-4D0B-92F6-DD961B1663BE%40datatravels.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Douglas Lovell
In reply to this post by Joe Guerra
Here is an open source project on GitHub that combines React with Rails:

https://github.com/wbreeze/socelect

It takes a monorepo approach, with the front-end JS code next to the back-end Rails. To integrate, it simply has the JS build (uses Parcel) output the transpiled, bundled javascript into the Rails assets/javascripts directory. It names the output without a fingerprint, because Rails asset pipeline will add one.

The idea was to keep it as simple as it can possibly be and have it work cleanly. It doesn't use the react-rails gem. It doesn't use separate repositories or servers. All of these gymnastics for scale are aspirational. Few projects ever reach the point of scale, especially when bogged-down in the gymnastics.

On Monday, August 19, 2019 at 3:48:03 PM UTC-3, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d2be7762-7226-4608-a1f4-9e1c73b1ae6e%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Joe Guerra
Thanks.

I found a portfolio app that runs on react.  Got it working locally, unfortunately can't figure out how to publish it to heroku.  (  I did follow a tutorial, most tutorials don't seem to work...)



On Tuesday, August 20, 2019 at 9:54:34 AM UTC-4, Douglas Lovell wrote:
Here is an open source project on GitHub that combines React with Rails:

<a href="https://github.com/wbreeze/socelect" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwbreeze%2Fsocelect\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEE-3M6QZzMo1pzDL0f7uQbF1e2KA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwbreeze%2Fsocelect\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEE-3M6QZzMo1pzDL0f7uQbF1e2KA&#39;;return true;">https://github.com/wbreeze/socelect

It takes a monorepo approach, with the front-end JS code next to the back-end Rails. To integrate, it simply has the JS build (uses Parcel) output the transpiled, bundled javascript into the Rails assets/javascripts directory. It names the output without a fingerprint, because Rails asset pipeline will add one.

The idea was to keep it as simple as it can possibly be and have it work cleanly. It doesn't use the react-rails gem. It doesn't use separate repositories or servers. All of these gymnastics for scale are aspirational. Few projects ever reach the point of scale, especially when bogged-down in the gymnastics.

On Monday, August 19, 2019 at 3:48:03 PM UTC-3, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/25316f42-6b48-4a57-b57c-27b4adbd9447%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Brent Mulligan
Is it an issue with the Heroku build failing? You may need to insert the heroku/nodejs buildpack infront of your heroku/ruby buildpack if it did not happen automatically. You can check by running `heroku buildpacks`, it should list something like 1. heroku/nodejs, 2. heroku/ruby.



On Thursday, August 22, 2019 at 10:20:58 AM UTC-4, Joe Guerra wrote:
Thanks.

I found a portfolio app that runs on react.  Got it working locally, unfortunately can't figure out how to publish it to heroku.  (  I did follow a tutorial, most tutorials don't seem to work...)



On Tuesday, August 20, 2019 at 9:54:34 AM UTC-4, Douglas Lovell wrote:
Here is an open source project on GitHub that combines React with Rails:

<a href="https://github.com/wbreeze/socelect" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwbreeze%2Fsocelect\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEE-3M6QZzMo1pzDL0f7uQbF1e2KA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwbreeze%2Fsocelect\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEE-3M6QZzMo1pzDL0f7uQbF1e2KA&#39;;return true;">https://github.com/wbreeze/socelect

It takes a monorepo approach, with the front-end JS code next to the back-end Rails. To integrate, it simply has the JS build (uses Parcel) output the transpiled, bundled javascript into the Rails assets/javascripts directory. It names the output without a fingerprint, because Rails asset pipeline will add one.

The idea was to keep it as simple as it can possibly be and have it work cleanly. It doesn't use the react-rails gem. It doesn't use separate repositories or servers. All of these gymnastics for scale are aspirational. Few projects ever reach the point of scale, especially when bogged-down in the gymnastics.

On Monday, August 19, 2019 at 3:48:03 PM UTC-3, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/87e67ae5-ed62-443e-822f-d0208afdfa73%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ROR + React

Joe Guerra
I was able to publish the create-react-app my-app   --> right below...


but I was wrapping my head around getting this portfolio up and running so I can add a few of my web projects online.  (of course, I'd edited it a bit, lol)




On Thursday, August 22, 2019 at 5:20:32 PM UTC-4, Brent Mulligan wrote:
Is it an issue with the Heroku build failing? You may need to insert the heroku/nodejs buildpack infront of your heroku/ruby buildpack if it did not happen automatically. You can check by running `heroku buildpacks`, it should list something like 1. heroku/nodejs, 2. heroku/ruby.



On Thursday, August 22, 2019 at 10:20:58 AM UTC-4, Joe Guerra wrote:
Thanks.

I found a portfolio app that runs on react.  Got it working locally, unfortunately can't figure out how to publish it to heroku.  (  I did follow a tutorial, most tutorials don't seem to work...)



On Tuesday, August 20, 2019 at 9:54:34 AM UTC-4, Douglas Lovell wrote:
Here is an open source project on GitHub that combines React with Rails:

<a href="https://github.com/wbreeze/socelect" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwbreeze%2Fsocelect\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEE-3M6QZzMo1pzDL0f7uQbF1e2KA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwbreeze%2Fsocelect\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEE-3M6QZzMo1pzDL0f7uQbF1e2KA&#39;;return true;">https://github.com/wbreeze/socelect

It takes a monorepo approach, with the front-end JS code next to the back-end Rails. To integrate, it simply has the JS build (uses Parcel) output the transpiled, bundled javascript into the Rails assets/javascripts directory. It names the output without a fingerprint, because Rails asset pipeline will add one.

The idea was to keep it as simple as it can possibly be and have it work cleanly. It doesn't use the react-rails gem. It doesn't use separate repositories or servers. All of these gymnastics for scale are aspirational. Few projects ever reach the point of scale, especially when bogged-down in the gymnastics.

On Monday, August 19, 2019 at 3:48:03 PM UTC-3, Joe Guerra wrote:
I'm going to rebuild my rails app and maybe add react on the front end.    I forget which version of rails I'm using, but I guess it would be best to start over with the latest.

Does anyone know of boilerplate or template that would include starting an app with the react & rails?  (maybe some other useful gems as well)

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b0ccb786-5585-4dd3-8a8f-a7d76f30b093%40googlegroups.com.