How to use SQL group clause with FOR UPDATE SKIP LOCKED in Rails? I’d prefer to use ActiveRecord as opposed to raw queries. I have a generic model called Job, which has an attribute called client_class, which I’d like to ...
databaseanswers.net Latest Questions
I created a Rake test: namespace :dev do DEFAULT_PASSWORD = 123456 desc "Sets up dev environment!" task setup: :environment do if Rails.env.development? show_spinner("Deleting database...") { %x(rails db:drop) } ...
I will go stright to the point: I have these two models: User Followed The Followed model has user_id (the user that follows another user) and followed_id, the user that is followed by the user with user_id. the User model looks like this: has_many :followeds, foreign_key: ...
I have a table with two foreign key fields: buyer_id and supplier_id. Schema.rb includes the following fields and indexes: t.bigint "buyer_id" t.bigint "supplier_id" t.index ["buyer_id"], name: "index_shipments_on_buyer_id" t.index ["supplier_id"], name: "index_shipments_on_supplier_id" # As shown in Postgres itself: "index_shipments_on_buyer_id" btree (buyer_id) "index_shipments_on_supplier_id" btree (supplier_id) I am running the same query ...
I’m trying to connect a rails app to a remote Postgres database (using the PG gem) and getting issues. I set my database.yaml file development: adapter: postgresql encoding: unicode database: testdb username: testuser password: "*******" host: ...
In rails 4, I want to get the last row of data inside scope. I have models called Abc, AbcRoot, AbcRootDisabling and inside Abc model, def self.including_abc_disablings joins('JOIN abc_roots_abcs as crc ' \ ...
I stumbled upon following issue. I’ve upgraded my postgres to version @13 by running brew install postgresql@13 – this installed version 13.8. I then added paths to my ~/.zshrc (for compilers too). Then I run source ~/.zshrc, even restarted the whole ...
The models in question are: User Followed The "followeds" schema(or table) has "user_id" that is a reference to "users" table And it has "followed_id" that is an integer. What I want to achieve: Inside my controller I want to select all ...
I am on mac os 12.5 Monterey. I type in psql and I get psql -U postgres Password for user postgres: psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "postgres" I am looking ...
I’m trying create a app with ruby on rails in termux, I already installed the necessary gems and packages for the setup, but when doing rails db:create. I get this error rails aborted! ActiveRecord::ConnectionNotEstablished: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: ...