Skip to main content
0 votes
0 answers
93 views

Rails Admin field filter in a has_one through relationship

I have a Remediation model which inherits from AssessmentHighRiskFactor model and added some custom show fields from other tables using relationships. The fields are visible and working fine, but I ...
Gonzalo's user avatar
  • 31
1 vote
0 answers
286 views

Paper trail not writing destroy events for join table soft deletes

I'm using paper trail in my app partially to display an audit log of changes and have noticed that it won't track destroy events when items in join tables are soft deleted (it works fine for other ...
lck's user avatar
  • 11
0 votes
2 answers
67 views

Passing a variable in an after_update action

I have an UserProfile model: class UserProfile < ApplicationRecord after_update :check_changes def check_changes AuditRecord.create(account_id: self.id, fields: self.saved_changes , ...
NaguiHW's user avatar
  • 167
1 vote
0 answers
97 views

How to decide for Single Table Inheritance in Rails and use multiple models in a unified view?

Let's say you run a content site for cartoon artists. Cartoon artists create a lot of resources: Drawings, Articles, Magazines, Books, Schemas, Projects, Courses, Lectures etc. Those resources have ...
Rich Steinmetz's user avatar
0 votes
0 answers
127 views

Rails Associations - has_one, belongs_to_many

It's been a while since I've worked with Rails (Rails 6) on a new application. I'm failing to recall how to properly set up associations. I have two problems that are rather similar and may help to ...
ryanpback's user avatar
  • 285
0 votes
1 answer
330 views

Can't mount newly generated Rails engine in an app

I have a complex Rails app and I want to extract some core functionality into an engine so that I can reuse the models etc in other Rails apps. I've been following the official documentation for ...
SkyNT's user avatar
  • 803
-1 votes
1 answer
801 views

How can i write a method that can generate scope dynamically which can be used for multiple models in ruby on rails

Currently, the existing scopes are like this. module TransactionScopes extend ActiveSupport::Concern included do scope :status, ->(status) { where status: status } scope ...
Ramachandra Hegde's user avatar
1 vote
2 answers
245 views

i18n-tasks custom scanner for enums

I would like to create a custom scanner for i18n-tasks that can detect enums declared as hashes in models. My enum declaration pattern will always be like this: class Conversation < ActiveRecord::...
JohnRDOrazio's user avatar
  • 1,624
0 votes
0 answers
258 views

How to avoid saving nil/blank in accepts_nested_attributes_for when displaying set number of fields for has_many association?

My question is an edgecase of how to avoid saving empty records on a nested rails form. I have a simple has_many, where a user can have a maximum of 5 job titles. # user.rb has_many :job_titles ...
stevec's user avatar
  • 55k
0 votes
1 answer
334 views

How to retrieve associated records through more than one other table?

Here's a simple setup where the user will always be a patient, and the user may or may not also be a physician: # user.rb has_one :physician has_one :patient # physician.rb belongs_to :user ...
stevec's user avatar
  • 55k
0 votes
2 answers
346 views

How to find out all the association of a model?

Say I have following models class User < ApplicationRecord devise :database_authenticable,:registerable :recoverable, :trackable, :validatable, :rememberable belongs_to :loginable, ...
ABN's user avatar
  • 1,150
0 votes
2 answers
42 views

Rails Associations (many to many)

I'm working with Ruby on Rails ActiveRecord and trying to realize my database structure. What I want is something link this: User id username License id name ActiveLicenses user_id (foreign key to ...
Andreas's user avatar
  • 41
0 votes
0 answers
136 views

What are the consequences of too many unnecessary associations in rails database?

Sometimes it feels natural or is at least tempting to make model associations based on columns that can be associated. But that doesn't mean they should be associated. What price does a database/app ...
stevec's user avatar
  • 55k
-1 votes
1 answer
331 views

Rails model default value being ignored when new record created?

I have a Message model like so class CreateMessages < ActiveRecord::Migration[6.0] def change create_table :messages do |t| t.text :body t.references :conversation, null: false, ...
stevec's user avatar
  • 55k
0 votes
1 answer
410 views

Add additional attribute on a has_many through in Rails

I have set up the following associations: class BookLaunch < ApplicationRecord has_many :book_launch_locations, dependent: :destroy has_many :stores, through: :book_launch_locations .... ...
lost9123193's user avatar
  • 11.1k

15 30 50 per page
1
2 3 4 5
25