Skip to content
This repository was archived by the owner on Jul 25, 2025. It is now read-only.

Commit 8f766a5

Browse files
Shpigfordclaude
andcommitted
Fix: Simplify article author management in Avo
- Remove direct author belongs_to field that was causing NoMethodError - Organize fields into tabs for better UX - Manage authors through the authorship association in the Author tab - Remove custom update_model_record that was interfering with saves Authors should now be managed through the authorship association: 1. Go to Author tab when editing an article 2. Edit the authorship record 3. Select/change the author there 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent afa8e16 commit 8f766a5

1 file changed

Lines changed: 8 additions & 25 deletions

File tree

app/avo/resources/article.rb

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,19 @@ class Avo::Resources::Article < Avo::BaseResource
1010

1111
def fields
1212
field :id, as: :id
13-
field :title, as: :text
14-
field :slug, as: :text
15-
field :content, as: :easy_mde
16-
field :publish_at, as: :date_time
1713
field :author_name, as: :text, hide_on: [ :forms ]
18-
field :author, as: :belongs_to, searchable: true, display_with_value: -> { record.name }
1914

2015
tabs do
21-
tab "Author Details" do
22-
field :authorship, as: :has_one
16+
tab "General" do
17+
field :title, as: :text
18+
field :slug, as: :text
19+
field :content, as: :easy_mde
20+
field :publish_at, as: :date_time
2321
end
24-
end
25-
end
26-
27-
def update_model_record(model, params, **args)
28-
author_id = params.delete(:author_id)
29-
30-
super(model, params, **args)
3122

32-
if author_id.present?
33-
# Remove existing authorship if present
34-
model.authorship&.destroy
35-
36-
# Create new authorship with the selected author
37-
model.create_authorship(author_id: author_id, role: "primary")
38-
elsif author_id == ""
39-
# If author_id is blank, remove the authorship
40-
model.authorship&.destroy
23+
tab "Author" do
24+
field :authorship, as: :has_one
25+
end
4126
end
42-
43-
model
4427
end
4528
end

0 commit comments

Comments
 (0)