Skip to content

Commit

Permalink
fix: resource fails to show when title is numeric (#3208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Sep 3, 2024
1 parent ac96632 commit cd8d0dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/avo/resources/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ def model_class
end

def record_title
fetch_record_title.to_s
end

def fetch_record_title
return name if @record.nil?

# Get the title from the record if title is not set, try to get the name, title or label, or fallback to the to_param
Expand Down
11 changes: 11 additions & 0 deletions spec/features/avo/resource_title_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "rails_helper"

RSpec.feature "Resource title option", type: :feature do
let!(:project) { create :project }

it "dont raise any error while visiting show viw with title as id" do
with_temporary_class_option(Avo::Resources::Project, :title, :id) do
expect { visit avo.resources_project_path(project) }.not_to raise_error
end
end
end

0 comments on commit cd8d0dc

Please sign in to comment.