Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `to_script' for nil:NilClass #31

Open
james-ai opened this issue Dec 27, 2023 · 1 comment
Open

undefined method `to_script' for nil:NilClass #31

james-ai opened this issue Dec 27, 2023 · 1 comment

Comments

@james-ai
Copy link

Description

Hullo.

I'm seeing the error below when running scaffold. It occurs when being run for single, or multiple tables, so it's similar to, but different from #14.

undefined method `to_script' for nil:NilClass

    attributes_list = attributes.map(&:to_script).reject { |x| x.nil? || x.empty? }.join(' ')
                                ^^^^

Table

#<SchemaToScaffold::Table:0x0000000101dcbb38 @name="competitions", @attributes=[#<SchemaToScaffold::Attribute:0x0000000101f208a8 @name="opta", @type="references">, #<SchemaToScaffold::Attribute:0x0000000101f20678 @name="perform", @type="references">, #<SchemaToScaffold::Attribute:0x0000000101f20498 @name="perform_code", @type="string">, #<SchemaToScaffold::Attribute:0x0000000101f202b8 @name="name", @type="string">, #<SchemaToScaffold::Attribute:0x0000000101f200d8 @name="created_at", @type="timestamptz">, #<SchemaToScaffold::Attribute:0x0000000101dcbd68 @name="updated_at", @type="timestamptz">, nil, nil]>

Cause

I've tracked the issue down to these two lines in my schema.rb file:

t.unique_constraint ["opta_id"], name: "competitions_opta_id_key"
t.unique_constraint ["perform_id"], name: "competitions_perform_id_key"

Once I delete those I'm able to run scaffold without issue.

Context

Ruby: 3.1.2
Rails: 7.1.2
OS: MacOS 12.6.3
Scaffold: 0.8.2

@james-ai
Copy link
Author

To clarify, I have to remove the unique_constraint lines from schema.rb completely. scaffold will still try to read the attributes if they are commented out like this:

# t.unique_constraint ["opta_id"], name: "competitions_opta_id_key"
# t.unique_constraint ["perform_id"], name: "competitions_perform_id_key"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant