Skip to main content

All Questions

1 vote
1 answer
81 views

ActiveRecord::NotNullViolation: RuntimeError: NOT NULL constraint failed: drives.created_at

I am using latest ruby 3.3.3 and latest rails 7.1.3.4. I am new to rails and I am learning it. Sorry if my request seems dumb to some. I got this error when I run tests. It seems that ActiveRecord is ...
Ghassen Rjab's user avatar
1 vote
1 answer
64 views

Rails Exception No Such Table Exists

I used rails generate to scaffold a ProjectType table and a ProjectGroup table that references project type. I created a project type successfully through the browser, but when trying to create the ...
baed's user avatar
  • 33
0 votes
0 answers
51 views

ActiveRecord - change in behaviour after rails upgrade from 6.1.7.6 to 7.0.1.7

We have similar logic in our application and that was working fine with rails version 6.1.7.6. After upgrading to rails 7.0.1.7, update_attribute method call at line 35 also inserting records into ...
Ram S's user avatar
  • 25
0 votes
0 answers
77 views

NoMethodError After Upgrade to ActiveRecord 7.1, But Removing ActiveRecord::Base.logger Fixes

For context, this is a Ruby 3.2 app on AWS Lambda with ActiveRecord 7.1.2. I can run this locally on my M3 MacBook irb with no problem. I can downgrade to ActiveRecord 7.0.8 and AWS Lambda (Ruby 3.2) ...
David Plappert's user avatar
0 votes
0 answers
33 views

Cannot reference records two levels lower with delegated_type directly

I designed the following model using STI in a Rails (Rails 7.0.8, Ruby 3.2.2) app. class Foo < ApplicationRecord belongs_to :user delegated_type :fooable, types: %w[Bar] end module Fooable ...
nrmn0006's user avatar
0 votes
1 answer
185 views

How can I dump an ActiveModel record as an INSERT SQL statement?

Previously with Rails 6 I have been doing: # I have an existing record record = MyRandomModel.take # Now I wanna get the INSERT SQL which would have been generated and executed on the DB ...
Niels Kristian's user avatar
0 votes
2 answers
99 views

Rails 7 many-to-many relationship, search for items with multiple related items

Assuming I have three models, some items, identifiers and a joining model in Rails 7 class Item < ApplicationRecord has_many :item_identifiers has_many :identifiers, through: :item_identifiers ...
Shuttleu's user avatar
  • 123
1 vote
0 answers
29 views

Establishing a many to many association with the .build method

I've been banging my head against this for a few days, and I know of a hacky work around but I'm trying to adhere to the "Rails Way" as much as possible. I have a Connector model, and a ...
Travis Courtney's user avatar
0 votes
0 answers
28 views

Resource not being deleted when calling destroy action [Rails 7]

I'm relatively new to rails, and I am working through a tutorial. The problem has been pointed out by one of the unit tests (using rails Minitest). Here test/controllers/carts_controller_test.rb I ...
Romo's user avatar
  • 45
0 votes
1 answer
32 views

Rails 7, trying to exclude applicants from a list of projects using joins

I have a Project model ... class Project < ApplicationRecord belongs_to :user has_many :applicants, dependent: :destroy end ... a User model ... class User < ApplicationRecord has_many :...
Frub's user avatar
  • 83
1 vote
1 answer
543 views

ActiveModel::NestedError attribute=survey_questions.survey, type=blank, options={:message=>:required}

I have the below models in a Ruby on Rails application(I am using Rails 7): class Survey < ApplicationRecord has_many :survey_questions, foreign_key: 'IdSurvey', dependent: :destroy ...
Behnam's user avatar
  • 1,045
1 vote
1 answer
95 views

Getting a TypeMismatch in Rails with Multiple Checkboxes

I am trying to create a multiple checkbox option on my form in Rails. The main error I get is: ActiveRecord::AssociationTypeMismatch in ContactsController#update ContactGroup(#114780) expected, got &...
Monroe Mann's user avatar
-1 votes
2 answers
55 views

Determine if reserved item is available when extending the reservation

I am having trouble with a scenario where a user edits their reservation in my tool borrowing application. Specifically when the user wants the same tool but needs to pick it up hours/days before and/...
dr.'s user avatar
  • 1,439
0 votes
1 answer
363 views

Enum on model being loaded twice after upgrade to Rails 7

I've just upgraded to Rails 7, and suddenly I'm having a very odd issue with one of my models. This is the model (please ignore the terrible naming of the keys and the fact that this would probably be ...
jeffdill2's user avatar
  • 4,084
0 votes
0 answers
856 views

How can I bulk insert records with UUID primary keys using insert_all in Rails?

I have a controller action which, upon creation of a parent object, generates and saves a batch of M-M associations. The database is Postgres and all relevant tables in the application use UUIDs. When ...
R. Barrett's user avatar

15 30 50 per page