Skip to main content
Filter by
Sorted by
Tagged with
3 votes
0 answers
125 views

Let's say I have this sample model structure: class Book has_many :stores end class Store has_many_attached :images do |attachable| attachable.variant :small, resize_to_limit: [ 64, 64 ] ...
aurefos's user avatar
  • 31
0 votes
1 answer
87 views

OK, the basis of the issue is a set of nested attributes is not persisting. The only oddity is that the attribute can be delegated to a delegate_parent. I don't think this should cause any issues, but ...
Romuloux's user avatar
  • 1,222
1 vote
1 answer
163 views

This code may be difficult to understand at first glance, but it was created solely to reproduce an unusual behavior and does not represent actual application code. Therefore, comments such as “the ...
megeton's user avatar
  • 23
0 votes
0 answers
111 views

I'm working on upgrading our Rails app from 7.1 to 7.2, and one of the changes is better support for PostgreSQL's composite primary keys. One of our models uses this feature, with the following line ...
Ben Sandeen's user avatar
  • 1,573
0 votes
1 answer
90 views

How to use activerecord-import to upsert only when values have changed? Body: I'm using the activerecord-import gem in a Rails 6 app to bulk upsert data into a PostgreSQL database. Here's an example ...
Raghvendra Rao's user avatar
0 votes
1 answer
61 views

I have 3 models where all of the associations work. I can do the duplicated voter_memberships/voters for contributor, editor, and manager, but I'd like it to be one association per role and not two. ...
anithri's user avatar
  • 340
0 votes
1 answer
95 views

I have this query without SELECT clause $itemList = Job::find('all', array('conditions' => array('jobs.deleted = ?' . $sql_conditional_fragment, 0), 'include' => array('job_type','...
cold-dumpling's user avatar
0 votes
1 answer
129 views

We are planning the migration to Rails 7.2.2.1 (we currently run on 7.1.5.1). We have noticed some errors during the CI run while querying with binding variable on integer column. For example : # ...
user30719238's user avatar
0 votes
0 answers
54 views

I have an ActiveRecord model with a monetary field I need to encrypt. I use gems lockbox and money-rails in this application for encryption and currency formatting, respectively. Unfortunately, they ...
David Hempy's user avatar
  • 6,404
2 votes
2 answers
168 views

This feels so much harder than I think it should! I have a Rails model: MarketplaceMessage Every message has an initial_record_id - if it's the first message, it's the ID of the record and if it's a ...
sethherr's user avatar
0 votes
2 answers
99 views

I get the following error on a query with PostgreSQL 16.8 on x86_64. It works fine on the other tables with the same query and unique index. I tried recreating the index multiple times, but no luck. ...
Amit Patel's user avatar
1 vote
1 answer
74 views

Can I get the same output of the SQL query below using ActiveRecord? SELECT d.title, COUNT(ep.*) FROM posts d LEFT JOIN comments ep ON d.title = ep.post_title GROUP BY d.title; I tried Post.joins(:...
Sig's user avatar
  • 6,150
0 votes
1 answer
220 views

I have some models that store the params of a user database query. They are not ActiveRecord database-backed models, more like what you might create with ActiveModel to compile and validate form ...
nimmolo's user avatar
  • 627
0 votes
0 answers
49 views

In a Rails app for managing course bookings, I want to keep the updated_at timestamps of related models in sync. Here's the setup: class ShopOrder < ApplicationRecord delegated_type :...
cuddlybunion341's user avatar
1 vote
1 answer
98 views

I'm trying to refactor a scope within a Concern so that the scope gets most of its logic by calling different class methods, depending on an arg. With "public" class methods, that works fine....
nimmolo's user avatar
  • 627
0 votes
0 answers
166 views

I need to create a Postgres table partitioned by range. The partitioning approach is essential because the table will need to store large volumes of data and be queried frequently. The plan is to set ...
fs314's user avatar
  • 129
1 vote
1 answer
68 views

Apologies of the title is convoluted but thats basically what I want to do. I have a Table, Building, that is Related to a Table Named Residents, and those Residents can have many Photos and other ...
WoodlandDev's user avatar
-1 votes
1 answer
90 views

Im trying to Monkey Patch the follwing ActiveRecord Model, But im having trouble getting it to stick. Im trying to prepend my module so that it overrides the Rails implementation of a private method ...
Derek's user avatar
  • 8,708
3 votes
3 answers
281 views

I have a Rails application using Postgres as the database. Postrgres does not accept strings containing null bytes (example: "a \u0000 b"). Trying to save such data leads to the following ...
lmtaq's user avatar
  • 570
0 votes
0 answers
41 views

I include an association with additional attribute projects_count. Even with the includes method, I still got N+1 queries for categories. I guess it's because of the dynamic argument in ...
Kevin's user avatar
  • 93
0 votes
1 answer
67 views

I have two models: class Product belongs_to :storage_box end class StorageBox validates :key presence: true, uniqueness: { scope: %i[kind] } validates :kind ...
Daniel Costa's user avatar
0 votes
0 answers
51 views

I have padrino version 0.15.3 and activerecord 7.2.I use task: padrino rake ar:migrate Errors: undefined method `schema_format' for ActiveRecord::Base:Class Did you mean? schema_cache
user29559775's user avatar
2 votes
1 answer
130 views

What is the difference between this: User.includes(:sites).where("sites.name = 'test'").references(:sites) and this: User.joins(:sites).where(sites: { name: "test"} ) Is there a ...
elabmot's user avatar
  • 115
1 vote
2 answers
227 views

When I create Padrino framework with SQLite3 and activerecord. padrino rake ar:migrate @schema_migration.create_table Or when: padrino rake ar:schema:dump undefined method `with_connection' for #...
user29559775's user avatar
0 votes
0 answers
50 views

I'm trying to connect to an old database to copy/process data to the current database (by Rails environment) (both sqlite). I want to execute raw SQL on the old one and create models in the new one, ...
stanley90's user avatar
  • 155
0 votes
0 answers
139 views

I am developing a Ruby gem that will be used by a Rails application. In it, I would like to use database connection (ActiveRecord::Base.connection) that the Rails app itself uses. The gem will be ...
tesnirs's user avatar
  • 97
-1 votes
1 answer
158 views

I got my application to weird state - when I create record (in application or in console), it is created in database, object reports to be persisted, but the object has no id (id: nil). In summary: ...
janpeterka's user avatar
0 votes
0 answers
80 views

I have a Ruby on Rails application that uses both Postgres and Neo4j databases. For certain records, data is first saved to Postgres, and then a callback is triggered to update the Neo4j database. ...
Lorenz's user avatar
  • 795
0 votes
2 answers
101 views

I have 2 models class A < ApplicationRecord has_one :b, dependent: :destroy has_one :c, dependent: :destroy end and class B < ApplicationRecord belongs_to :a validates :ip_address, ...
Abhimanyu Patil's user avatar
1 vote
0 answers
208 views

I was successfully added a vector field on my database create_table :scraped_documents do |t| t.references :client, null: false, foreign_key: true t.column :embedding, :vector, limit: 1536 ...
Petran's user avatar
  • 8,137
0 votes
2 answers
117 views

Happens both at Rails V 5.2.8.1 and Rails 7.1.3.2 My models: class User < ApplicationRecord has_and_belongs_to_many :comments end class Comment < ApplicationRecord belongs_to :book ...
Roko's user avatar
  • 1,355
0 votes
1 answer
69 views

I have a json column in an Answer table in a rails app; document. I'm trying to write a scope which returns true if the document is empty, or if it contains only one of two specific keys. With ruby we ...
Phil Brockwell's user avatar
0 votes
0 answers
55 views

I have a Sidekiq Job that syncs one of my models to an external source. This is a - let's say expensive - operation, that I would like to run only when needed. Reading the current state of the ...
Ákos Vandra-Meyer's user avatar
0 votes
0 answers
68 views

Is there a cleaner way of associating a has_one...through relationship if the original object can have one and only one relationship through a couple of different objects (i.e. in the example below, ...
Jacob Miller's user avatar
0 votes
1 answer
59 views

I have quite a weird situation here in my Rails App. I have an API call for uploading documents, namely PDFs, which get attached to a Document object via has_one_attached :file in its class definition....
JCMcRae's user avatar
  • 257
1 vote
1 answer
143 views

class Product < ActiveRecord::Base actable as: :as_product end class Car < ActiveRecord::Base acts_as :product, as: :as_product end class Truck < ActiveRecord::Base acts_as :...
Matey Johnson's user avatar
0 votes
0 answers
54 views

model class User < ApplicationRecord validates :name, uniqueness: true end schema create_table 'users', force: :cascade, charset: 'utf8mb4', collation: '...
52zxc's user avatar
  • 1
0 votes
0 answers
61 views

I am trying to do search functionality for my Rails MVC learning. I am adding title , description and category name as filter columns. And checking each parameter id defined in my model class using ...
Mr.DevEng's user avatar
  • 1,698
1 vote
1 answer
86 views

I am working on a Rails application that uses ActiveRecord::SessionStore for session management. While debugging, I noticed an interesting behavior regarding the session_id. Here's what I found: The ...
sajid chowdhury's user avatar
-2 votes
1 answer
54 views

I have a pretty basic Yii2 ActiveRecord query. $paperList = Paper::find()->orderBy(['id' => SORT_DESC])->all(); id is my primary key column which is of type int and AUTO_INCREMENT. When ...
Quentinb's user avatar
  • 510
0 votes
1 answer
46 views

In my Rails application, I have a Project model with an associated Task model (Project has many tasks). Each Task has a field called parent_task_id that links it to a task from a previous version. ...
MOin's user avatar
  • 71
0 votes
0 answers
68 views

I have a "central" model that is referenced by many other models like this: class Survey < ApplicationRecord has_one :foo_a, foreign_key: :survey_a_id, inverse_of: :survey_a, class: '...
Jordan Ell's user avatar
  • 1,835
0 votes
1 answer
100 views

I'm trying to implement partitioning in PostgreSQL. The problem is that one partitioned table references another partitioned table. There is also a third regular table that also references the ...
Colibri's user avatar
  • 1,225
1 vote
1 answer
119 views

I upgraded our rails application from version 6.0 directly to 7.0. After commenting out the new framework defaults everything seemed to work smoothly but after setting the load_defaults to 7.0 I got ...
Vakmeth's user avatar
  • 11
0 votes
0 answers
57 views

I have a model where each record has an image with a :background field that is used on the frontend. Paperclip is already used in the project, and in the admin panel, I can upload this image, so that ...
Procy's user avatar
  • 49
2 votes
1 answer
100 views

I am in a situation in which I am forced to use nested transactions: I have several methods that save a bunch data, each of them needs to be wrapped in a SQL transaction, and they also have to call ...
Adriano di Lauro's user avatar
0 votes
1 answer
354 views

I am attempting to utilize binding parameters in Rails using ActiveRecord::Base.connection.exec_query for a mysql database, but I'm doing something wrong. Here is the code: query = "Select * from ...
Neil's user avatar
  • 4,740
0 votes
1 answer
58 views

I am writting a method that reassigns a polymorphic collection like: class Color < ApplicationRecord belongs_to :colorable, polymorphic: true end class Table < ApplicationRecord has_many :...
fguillen's user avatar
  • 39.5k
0 votes
0 answers
82 views

class ModelName < ApplicationRecord ... end For example, purpose "ModelName" has a column name 'example_column' with type of enum array. Let's consider the enums are "first", ...
Sushan Sapaliga's user avatar
0 votes
0 answers
55 views

I have two models in Rails: # Product has_many :product_prices belongs_to :associated_product, class_name: 'Product', optional: true has_many :associated_products, class_name: 'Product', foreign_key: :...
user12178999's user avatar

1
2 3 4 5
579