Live data from Hacker News

Ruby on Rails Tutorial

railstutorial.org

31–40 of 82 posts

Re: Ruby on Rails Tutorial

#31

Earlier quoted context omitted.

PHP has a lot less "magic" in it, so using it will force you to learn a lot of concepts and conventions that Rails takes care of for you (which can have its negatives).

PHP can be compared to Ruby. Rails can be compared to Symfony or Laravel. It makes little sense to compare a language to a framework though.

Yes, I was using the terms interchangeably - my bad. Still, Rails has a lot more conventions and magic than Laravel (I don't know about Symfony). Compared to Laravel, you have to deal with a lot less configuration to get up and running. That's what makes it such an attractive choice for beginners: you can work on developing features right away without having to fiddle with stuff. I say this as someone who has used both.

Re: Ruby on Rails Tutorial

#32

Earlier quoted context omitted.

Are there any recent, up-to-date and comprehensive tutorials that show how to use React with Rails while following the conventions of both frameworks? Every tutorial I've seen focuses on either one, but I haven't found one that focuses on both.

There's a reason why you don't see specific Rails+React tutorials - since they're just communicating with each other other JSON, Rails doesn't need to know or care that it's React, Angular, or whatever on the other end. The reverse is true for React, it doesn't care where the data's coming from. You'd simply want to look for a Rails tutorial that focuses on building an API using Rails. It's probably slightly easier t…

Yeah, I actually know both Rails and React, and have built stuff with them separately. I understand they would talk to each other using JSON and don't need to be "aware" of each other.

The main thing that I find confusing is the build/deployment process of a Rails application that uses React as the front-end. For example, let's say that I develop a Rails/React app and want to deploy it. Do I run webpack first to transpile the React app to "regular" JavaScript, then git commit, then push to Heroku? Or does Heroku do that for me? Also, how does the Rails asset pipeline come into play? Any special configurations? Etc.

Re: Ruby on Rails Tutorial

#33

Earlier quoted context omitted.

There's a reason why you don't see specific Rails+React tutorials - since they're just communicating with each other other JSON, Rails doesn't need to know or care that it's React, Angular, or whatever on the other end. The reverse is true for React, it doesn't care where the data's coming from. You'd simply want to look for a Rails tutorial that focuses on building an API using Rails. It's probably slightly easier t…

Yeah, I actually know both Rails and React, and have built stuff with them separately. I understand they would talk to each other using JSON and don't need to be "aware" of each other. The main thing that I find confusing is the build/deployment process of a Rails application that uses React as the front-end. For example, let's say that I develop a Rails/React app and want to deploy it. Do I run webpack first to tran…

If you're going down the road of a React based SPA on top of a Rails API (and I'd question hard if you'll really benefit from that) do yourself a favour and just treat them as entirely separate applications. The backend deploys as you'll be used to with Rails, and the front-end can be built locally and then pushed to anywhere that'll serve some static HTML.

Re: Ruby on Rails Tutorial

#34
I recently joined a company that's built on Rails. I previously was most comfortable with Python/Django. There's lots of code to crib from, and I've picked up the basics pretty quickly.

That said, I've been looking for Rails tutorials/resources that are geared toward someone with decent experience with other languages/frameworks. Would y'all recommend this book, or is this more of "learn to code with Ruby on Rails"? If not this, any other resources that fit the bill?

Re: Ruby on Rails Tutorial

#35

I recently joined a company that's built on Rails. I previously was most comfortable with Python/Django. There's lots of code to crib from, and I've picked up the basics pretty quickly. That said, I've been looking for Rails tutorials/resources that are geared toward someone with decent experience with other languages/frameworks. Would y'all recommend this book, or is this more of "learn to code with Ruby on Rails"?…

For someone who already knows how to program and just wants to learn Rails, the official guides[1] are top notch and a great way to learn the framework without having to read a whole book

[1] http://guides.rubyonrails.org/

Re: Ruby on Rails Tutorial

#36

Earlier quoted context omitted.

There's a reason why you don't see specific Rails+React tutorials - since they're just communicating with each other other JSON, Rails doesn't need to know or care that it's React, Angular, or whatever on the other end. The reverse is true for React, it doesn't care where the data's coming from. You'd simply want to look for a Rails tutorial that focuses on building an API using Rails. It's probably slightly easier t…

Yeah, I actually know both Rails and React, and have built stuff with them separately. I understand they would talk to each other using JSON and don't need to be "aware" of each other. The main thing that I find confusing is the build/deployment process of a Rails application that uses React as the front-end. For example, let's say that I develop a Rails/React app and want to deploy it. Do I run webpack first to tran…

Webpack and the asset pipeline overlap in responsibility, so you probably want to stick with one or the other. There may be some edge cases that I don't know about where you might want functionality from both, though.

I personally use webpack and transpile/bundle all the javascript and styles into a `build` directory that gets served by nginx.

For my side projects, I use a really simple express server with a single handler for all routes that pre-renders the react app and sends it down to the client for rehydration. After that, the client takes over and sends requests directly to the api server (rails in this case). Your boilerplate setup is an nginx reverse proxy that forwards all requests to /api/* to the rails server, and everything else goes to the express server.

For easy reproduction, you can use a docker cluster with a configuration something like this:

    version: "2"
    services:
      www:
        image: "nginx:1.10.1"
        restart: "always"
        volumes:
          - "./node/dist:/usr/share/nginx/html/dist"
          - "./nginx/default.conf:/etc/nginx/conf.d/default.conf"
        ports:
         - "8080:80"
        links:
          - "app:app"
          - "api:api"
        container_name: "react-rails_www"
      app:
        build:
          context: "."
          dockerfile: "Dockerfile-node"
        image: "username/react-redux:0.0.1"
        volumes:
          - "./node:/home/app/src"
        ports:
          - "3001"
        container_name: "react-rails_app"
        command: "npm start"
      db:
        image: "postgres"
        container_name: "react-rails_db"
      api:
        build:
          context: "."
          dockerfile: "Dockerfile-rails"
        command: "bundle exec rails s -p 3000 -b '0.0.0.0'"
        volumes:
          - "./rails:/home/app/src"
        ports:
          - "3000"
        depends_on:
          - "db"
        container_name: "react-rails_api"
And your nginx conf:

    server {

      listen 80;
      server_name localhost;
      charset utf-8;

      location /dist {
        alias /usr/share/nginx/html/dist;
      }

      location /api {
        proxy_pass http://api:3000;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
      }

      location / {
        proxy_pass http://app:3001;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
      }

    }
This is a good reference boilerplate for setting up react and webpack with pre-rendering on the server: https://github.com/colinmeinke/universal-js

Re: Ruby on Rails Tutorial

#37
This is the book that finally led me to abandon Law and become a developer. It finally "clicked" after reading this book and, later, taking the Pragmatic Programmers Rails & Ruby courses.

I even bought the complete pack with the videos after reading just to show my appreciation to Hartl.

Re: Ruby on Rails Tutorial

#38

Earlier quoted context omitted.

Yeah, I actually know both Rails and React, and have built stuff with them separately. I understand they would talk to each other using JSON and don't need to be "aware" of each other. The main thing that I find confusing is the build/deployment process of a Rails application that uses React as the front-end. For example, let's say that I develop a Rails/React app and want to deploy it. Do I run webpack first to tran…

If you're going down the road of a React based SPA on top of a Rails API (and I'd question hard if you'll really benefit from that) do yourself a favour and just treat them as entirely separate applications. The backend deploys as you'll be used to with Rails, and the front-end can be built locally and then pushed to anywhere that'll serve some static HTML.

^^^ This. Unless you're building a CMS with a large and complicated administration UI, an SPA is probably overkill and will needlessly complicate your development process.

Re: Ruby on Rails Tutorial

#39
I am surprised this hasn't been submitted dozens of times in the past.

For those who don't know -- and I guess there are always new people -- this is probably the most famous Rails tutorial on the web.

It has the following impressive attributes:

1. Free

2. Goes through a good process

a. Backs up code to Git

b. Tests the code

c. Deploys it to Heroku

Other paid tutorials are often versions of this one.

Re: Ruby on Rails Tutorial

#40
post #17
post #3

I'll always be upset that my college web development class got changed from following this tutorial to early 2000s PHP without a database.

You know, I'll probably be bammed for saying this, but reading through this very well-made tutorial gave me the opposite reaction. I am glad I learned and still use PHP and not RoR. IMHO, there are way too many black-boxes and unnecessary abstractions for such a simple pattern as MVC, which is really nothing more then connecting HTML views to database fields view URI routes. I recently struggled through my first Ioni…

No. With that stack you can build business and make money. Not a toy app.

That being said, if you were doing a toy app then you would take out PG. You don't need all the dev gems they just make your life easier / faster startup. If you come from php then you like to make your life hard, so webconsole and byebug are out. Your doing a toy app so you don't need turbolinks, coffescript, or Sass. It's a toy so what does it matter if a person downloads 3MB of javascript. Take out uglifier. You're not doing an API so jbuilder is gone.

This is the new Gemfile.

  gem 'rails',        '5.0.0'
  gem 'sqlite3', '1.3.11'

People make Rails out to be some magical monster that know one knows what is going on. It's just Ruby at the end of the day.

Here is a single file rails boot, that includes downloading the gems and running a test.

https://github.com/rails/rails/blob/master/guides/bug_report...

Post reply on HN