Git Product home page Git Product logo

quotes's Introduction

Quotes App - Rails 7 and hotwire

Hotwire is amazing. It took all the good things Rails already did and improved it into a technique that allows you to write little(sometimes none) Javascript.

That's great for developers that want to write their full stack application but don't want to have trouble writing or learning React/Typescript/Vue and the whole modern stack frontend developers use these days.

Real time updates with turbo-stream which abstracts all the javascript part from Action Cable and turbo-frames for replacing only parts of pages gives your rails application the look and feel of any other app writen in React or any JS library.

So, give it a chance and try it yourself to build something with it.

Following the tutorial:

I wrote this application based on this tutorial with some changes that combined serve as the foundation for all my Rails projects.

First, the changes:

I used Rspec as a test framework instead of Mini-test and I wrote a small class to dry-up a the controller responses. Normally I use the responders gem for this, but somehow it's not working with flash messages and turbo stream response format.

Now, let me walk you through the foundation:
  1. Docker. I always use docker no matter what. If you get my laptop the only thing installed is a docker desktop application. Nothing else, no database, no programing language, nothing. Even when I need to run one ruby script, I use docker. Follow this tutorial for docker and rails quick start.
  2. Devise Gem for user management, including login, registration, forget the password, and so on.
  3. Simple Form gem plays nice with devise so you can build forms with ease. You set up one time and all your forms will be ready to reuse throughout the whole application.
  4. Rspec gem for tests. Nothing against the default rails test framework, but I feel much more productive with Rspec. Along with it, I also use shoulda-matchers, faker, factory_bot_rails, and rspec-its.
  5. Rubocop. It helps me write better quality code and once you use it's hard to go back.
  6. Dotenv-rails for better management of environment variables.
  7. Simplecov for checking if I'm covering at least 90% of the project with tests.
One note about tests:

Normally I write tests for all models trying to cover all possible edge cases.

Then I write feature tests using capybara which also acts as integration and end 2 end tests. If I'm writing an API-only application then I favor requests tests. Do not write controller tests. Favor always features or requests over controller tests.

Prerequisites

  1. Install docker

Running using docker

  1. Everything is set, just run spin up the container.
docker compose run --rm web bash rails db:prepare
docker compose up

Tests

You can run the tests using rspec: Tests Linting

docker compose run --rm web bash bundle exec rspec

Deployment

This version is not deployed anywhere but you can see how it is supposed to work here.

quotes's People

Contributors

dviana19 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.