From ecb2850a04adc6c6665f9a30a1d60ca73965ccfa Mon Sep 17 00:00:00 2001 From: Rasesh Patel Date: Wed, 24 May 2017 01:34:07 -0400 Subject: Show object ids in scaffold pages when displaying referenced objects Resolve Issue#29200 When scaffolding a model that references another model the generated show and index html pages display the object directly on the page. Basically, it just shows a memory address. That is not very helpful. In this commit we show the object's id rather than the memory address. This updates the scaffold templates and the json builder files. --- railties/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt | 2 +- railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails/generators/erb/scaffold') diff --git a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt index e1ede7c713..2cf4e5c9d0 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +++ b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt @@ -16,7 +16,7 @@ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %> <% attributes.reject(&:password_digest?).each do |attribute| -%> - <%%= <%= singular_table_name %>.<%= attribute.name %> %> + <%%= <%= singular_table_name %>.<%= attribute.column_name %> %> <% end -%> <%%= link_to 'Show', <%= model_resource_name %> %> <%%= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>) %> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt index 5e634153be..7deba07926 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +++ b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt @@ -3,7 +3,7 @@ <% attributes.reject(&:password_digest?).each do |attribute| -%>

<%= attribute.human_name %>: - <%%= @<%= singular_table_name %>.<%= attribute.name %> %> + <%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>

<% end -%> -- cgit v1.2.3