This tutorial inspects turning on each setting of
new_framework_defaults_7.0.rb file. The intended goal is to fully migrate to Rails 7's default set-up.
Rails.application.config.action_view.button_to_generates_button_tag = true
The button_to helper had inconsistent behaviour. Rails PR.
- string argument:
- block argument:
# 'new' is the string argument <%= button_to "New", new_task_path %>
<input type="submit" value="New">
Rails.application.config.action_view.apply_stylesheet_media_default = false
stylesheet_link_tag can specify a media type. When omitting a media attribute,
screen is no longer set as the default media value Rails Guide.
<%= stylesheet_link_tag "application" %>
<link rel="stylesheet" href="...css" media="screen">
<link rel="stylesheet" href="...css">
Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
Ensures all foreign key constraints are valid after fixtures are loaded in tests. Rails PR
# test/fixtures/parrots.yml george: name: "Curious George" pirate: redbeard # test/fixtures/pirates.yml blackbeard: name: "Blackbeard"
Fixtures can refer to a missing association.
parrots(:george).pirate will be
An error is raised when fixtures are loaded in tests.
"Foreign key violations found in your fixture data. Ensure you aren't referring to labels that don't exist on associations."
Top comments (5)
Any tips on how to get info on which fixture has the violation?
Did you find a solution? 🤦♂️
I used VS Code to open the local copy of Active Record and edited out a statement that was suppressing the backtrace. Then I could see where the errors were coming from.
Fantastic!! Do you remember exactly what you changed?
No, but I think it was a statement in the AR Postgres adapter that rescues a PG exception and returns false instead, which then causes AR to raise the fixture error.