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

Super_scaffold generator: _id field causes error #1456

Closed
swombat opened this issue May 13, 2024 · 2 comments · Fixed by bullet-train-co/bullet_train-core#844
Closed

Super_scaffold generator: _id field causes error #1456

swombat opened this issue May 13, 2024 · 2 comments · Fixed by bullet-train-co/bullet_train-core#844

Comments

@swombat
Copy link

swombat commented May 13, 2024

➜  promptcraft git:(main) ✗ rails generate super_scaffold Output PromptExecution,Prompt,Project,Team label:text_field results:text_area input_tokens:number_field output_tokens:number_field message_id:text_field user_rating:number_field
/Users/danieltenner/.rvm/gems/ruby-3.3.0/gems/activesupport-7.1.3.2/lib/active_support/inflector/methods.rb:290:in `const_get': uninitialized constant Message (NameError)

This is the message id returned by OpenAI, Anthropic, etc - not an internal id. I think this should be able to work as is, but I guess the workaround will be naming it something else, without _id at the end... Feels like it should be possible to have a text field called something_id though.

@ndbroadbent
Copy link

ndbroadbent commented May 25, 2024

I ran into this as well with fields like api_token_id and token_id - I'm setting up some models for API integrations where I enter API token IDs and secrets. I can see why _id is treated as a special case though, so maybe I'll go with _identifier for now.

@jagthedrummer
Copy link
Contributor

You can disable this particular _id related behavior by including the {vanilla} on the field in your super scaffolding command.

For instance:

rails generate super_scaffold SomeModel Team some_id:text_field{vanilla}

We're supposed to show you a message about that if we can't find the model but there's currently a bug. I think it will be fixed by this PR: bullet-train-co/bullet_train-core#835

jagthedrummer added a commit to bullet-train-co/bullet_train-core that referenced this issue Jun 4, 2024
…e` option

Fixes: bullet-train-co/bullet_train#1456
Fixes: bullet-train-co/bullet_train#1507

This makes it so that if someone super scaffolds a field that ends with
`_id` but does not explicitly include a `class_name` option then we'll
try to guess the `class_name` based on the name of the field.

For instance if you do this:

```
rails g super_scaffold Task Team event_id:super_select
```

We'll guess that `event_id` is a reference to the `Event` class. If we
can find an `Event` class in your app then everything proceeds as if you
had done this:

```
rails g super_scaffold Task Team event_id:super_select{class_name:Event}
```

If we can't find an `Event` model then you'll get a message saying so
and telling you about the `{vanilla}` option that you can use to disable
the `_id` related magic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants