Ignacio Alonso

Joined

3,940 Experience
38 Lessons Completed
0 Questions Solved

Activity

As a note, for devs with PR process, this setup will cause to be n+1 since you'll be triggering runs on any push without considering the branch, a better approach would be to only count pushes to main, something like this would work:

name: CI
on:
  pull_request:
    branches:
      - "*"
  push:
    branches:
      - main
      - master

Posted in How to send Webhook?

+1

For anyone who wants to use Models in tasks, you should load your environment on your task to load them before using them on the code as in:

task example: :environment do
end

Posted in Rails + Javascript question

Hey guys,

I have an app for generating orders containg products. I'm currently using a “cart” through table that helps me connect both orders and products. I would like to have a list of products where users can select what they want from the list via checkbox for e.g. and then add them to an array that would be sent to my controller but I don’t want to reload page on each product add from the list. What would be the best way to add the X number of products to the params after user ’adds' them to the cart and press send?

Posted in New Ruby/Rails site with documentation

This looks good. Thanks for sharing!

Im trying to make a project to practice more kinds of associations would you kindly help me understand this?

The basic idea is to have a betting game where one user generates a new bet that can only be accepted by another user (only 2 competitors assigned for each bet, the creator and the other player).

I’m thinking about 2 tables:

users

bets

Normally I would just have a one to many relationship for the user that created the bet. But I’m confused about the ‘competitor’ column where another user is also a user with a user_id. How can I express this relationship better than this:

After thinking it through it doesn’t look like a good setup because I’m renaming a column where I’m storing the user_id and having a many to many ‘through’ model doesn’t make sense since it is a “only one competitor can participate in that bet”.

I was thinking about a ‘one to one through’ creating a ‘competitors’ table like so:

Could you explain to me how to build it in a better way?

Many thanks!