I am trying to decide what is a better approach to manage Ruby on Rails and React in my application. I am using RoR 5 and gem react_on_rails
which makes everything works fine for me. The question is if I should build a REST API with RoR and then access it through the React to control the behavior of the components that I need.
The problem that I found and I could not find a solution at now is that I cannot put props from the controller in which I have two different props. For example,
class FooBarsController < ApplicationController
def index
@product_props = Product.all
@testimonial_props = Testimonial.all.where('featured', [true])
end
end
This is what I am doing in the view
<%= react_compontent('FooBarProduct', props: @product_props) %>
<h2>Title</h2>
<%= react_compontent('FooBarTestimonial', props: @testimonial_props) %>
I know that the logic of the controller should not manage two variables at once. it means that I cannot put my two tables in one place and I have to handle the business logic on the model.
In this case what would the best way to handle React props through REST API or Controller props even if I overloading the controller?