From Rails to React; Conceptual Differences in Frameworks

Ruby on Rails developer. Built this website. No React experience. My front end is 100% html.erb (plus AJAX / javascript for the fancy bits).
Learning how to code (Elixir + React for the moment) in a Portuguese start-up after having completed a coding bootcamp (Le Wagon) in December 2019.
Follow this Taaalk

3 followers

659 views

Zoe Gold
14:43, 03 Jun 20 (edit: 14:56, 03 Jun 20)
Hey Joshua, here is an interesting explanation about the differences between Rails and React, that I experience everyday.
Rails is primarily meant to handle backend operations such as database querying and management. [...] It is possible to handle front end tasks with Rails but that is not what it is best suited for, as there are other available frameworks which are much more equipped to deal with the front end, which brings us to React. [...]
In contrast to Rails, React is a client-side framework, meaning it deals more with frontend concerns, such as showing controls, rendering, playing sound and video, etc…
[At last] React doesn’t use templates, unlike Rails, where every page must have a template (the HTML or ERB file) to show to the user.
Joshua Summers
18:13, 03 Jun 20 (edit: 18:15, 03 Jun 20)
Right! Hello Zoe 👋 and thank you for the introduction.
So firstly we both left the bootcamp knowing the same thing.
In a controller there is function for a certain type of page - e.g. the 'index' page. Which provides data to be passed to the view (an index.html.erb file) in the form of an instance variable.
class DogsController < ApplicationController
  def index
    @dogs = Dog.all
  end
end
Which would have an index.html.erb file of:
<h1>All the Dogs!</h1>

<% @dogs.each do |dog| %>
  <h3><%= dog.name %></h3>
  <p><%= dog.description %></p>
<% end %>
And all my doggy data would pour out onto the index page.
First things first, if I'm working with React, a frontend framework which isn't within Rails, am I still sending data to the front end using an instance variable (i.e. @dogs)?
Follow this Taaalk

3 followers

659 views

Start your own Taaalk, leave your details or meet someone to Taaalk with.