Skip to content

Commit cd8d0dc

Browse files
authored
fix: resource fails to show when title is numeric (#3208)
1 parent ac96632 commit cd8d0dc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/avo/resources/base.rb

+4
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ def model_class
395395
end
396396

397397
def record_title
398+
fetch_record_title.to_s
399+
end
400+
401+
def fetch_record_title
398402
return name if @record.nil?
399403

400404
# 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
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "rails_helper"
2+
3+
RSpec.feature "Resource title option", type: :feature do
4+
let!(:project) { create :project }
5+
6+
it "dont raise any error while visiting show viw with title as id" do
7+
with_temporary_class_option(Avo::Resources::Project, :title, :id) do
8+
expect { visit avo.resources_project_path(project) }.not_to raise_error
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)