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

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
0 votes
2 answers
67 views

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
0 votes
0 answers
127 views

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
-1 votes
1 answer
804 views

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
0 votes
0 answers
258 views

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
  • 55.2k
0 votes
2 answers
347 views

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
0 answers
136 views

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
  • 55.2k
0 votes
1 answer
410 views

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
1 vote
2 answers
520 views

I have the following class User < ApplicationRecord has_one :physician end and class Physician < ApplicationRecord belongs_to :user end Since a user can only have one physician, I was ...
stevec's user avatar
  • 55.2k
1 vote
2 answers
1k views

I have a model Document in my rails application. It has columns name, and key. In my controller for create action, I get document name from the frontend and dynamically set one value for key with ...
Ashish's user avatar
  • 4,370
2 votes
2 answers
501 views

I created a Rails 5 app with config.api_only set to true, and implemented a controller action that deletes a record in a scoped model Message the problem is that when I try to delete a record that ...
Ivan Garcia's user avatar
0 votes
2 answers
82 views

I have 3 models user, micropost, like I followed Ruby on Rails Tutorial by Michael Hartl https://rails-4-0.railstutorial.org/book Now I am adding new features and was trying to add a like button and ...
Glitch_Znab's user avatar
1 vote
2 answers
82 views

In my model definition, I have # models/my_model.rb # == Schema Information # # Table name: my_models # # id :bigint not null, primary key # another_model_id :bigint # ...
absolutelydevastated's user avatar
1 vote
1 answer
145 views

I have a user model that I want to assign to be teacher or student( teacher and student are two separated model ) because if the user signup he would have different registration fields depending on if ...
kubet's user avatar
  • 55
0 votes
1 answer
132 views

Let's suppose I have 3 models, A, B and C (where A has many B, and B has many C): class A < ActiveRecord::Base has_many :bs end class B < ActiveRecord::Base belongs_to :a has_many :cs ...
Patricio S's user avatar
  • 2,130
0 votes
2 answers
2k views

I am trying to create a model in a controller using strong params in Rails 5.1 (some things changed from previous for strong_params). However, when I inspect the params, the merged ones are NOT ...
user58446's user avatar
  • 269
1 vote
2 answers
1k views

I've created new fields, "first_name", "last_name", "email", and "password" in the model generated migrate file as shown: class CreateUsers < ActiveRecord::Migration[5.2] def up ...
Brennan's user avatar
  • 35
4 votes
2 answers
2k views

I have a user model that has one profile. The profile has attribute such as name, gender, age, dob, designation. No fields in profile are mandatory. The user is created by an admin from only an email ...
sonm10's user avatar
  • 63
0 votes
2 answers
64 views

I have two models, Hotel and Room. I want to create a form that will allow me to add a new hotel and rooms, which indicates the name of the hotel and the quantity of rooms. I know I should use "nested ...
Kirill Zhuravlov's user avatar
-1 votes
1 answer
181 views

A student gets admitted to a school and in its admission form, I want the user to assign student his/her batch and grade as well. Batch has many grades and grade belongs to batch. In this scenario, I'...
Talha Meh's user avatar
  • 547
1 vote
1 answer
44 views

I've got a model that I'm using a collection_select on and I'd like to scope it to show only accounts that are open. To accomplish this, I've added a boolean field to my account model, defaulting to ...
PSCampbell's user avatar
2 votes
3 answers
1k views

Below are two tables with some sample data :- Uploads: id: 1 , file_ref:abc id: 2, file_ref: abc1 id: 4, file_ref: abc3 id: 5, file_ref: abc4 id: 6, file_ref: abc5 id: 7, file_ref: abc6 ...
Abdul Haseeb's user avatar
0 votes
1 answer
502 views

So I have a User model created with devise and a Project model. A Project should have one Project owner and project members. So now I have no idea how to create the relations in my models. What I ...
I.B's user avatar
  • 2,933
0 votes
1 answer
114 views

I am trying to override an existing active record model but the new active record model doesn't have methods from the old active record model. Here is the code that I am trying to use class ModelA &...
Sana's user avatar
  • 9,935
1 vote
4 answers
60 views

I have over thought this to the point that I'm only getting confused now. I have a Rails app with the following as models: User, Site, Tutorial, TutorialStep. A user can create many tutorials and ...
stevenpslade's user avatar

1
2 3 4 5
8