Use chaves UUID no Active Record

Identifique e associe seus modelos ActiveRecord usando UUIDs validados. gem ‘uuid’gem ‘activesupport’gem ‘activerecord’gem ‘sqlite3’require ‘active_support’require ‘active_record’require ‘uuid’ActiveRecord::Base.establish_connection adapter: “sqlite3”, database: “:memory:”;ActiveRecord::Schema.define do self.verbose = false create_table :posts, id: false, primary_key: …

Continuar lendo

Rails une escopos

class Answer < ActiveRecord::Base belongs_to :user belongs_to :question scope :user_answers, -> { where (user_id: current_user.id) } scope :user_answers_with_questions, -> { joins(:questions) & Answer.user_answers }end

Continuar lendo