-
Notifications
You must be signed in to change notification settings - Fork 22k
Issue #29200 scaffold an object with a reference displays an object memory address to user #29204
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
Issue #29200 scaffold an object with a reference displays an object memory address to user #29204
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @pixeltrix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
72c86e8
to
4d70cb1
Compare
0ab54ec
to
1e2d694
Compare
c631146
to
352566f
Compare
@pixeltrix Mergeable? |
@maclover7 @pixeltrix any thoughts or todo on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still relevant in Rails 6.0.0.alpha 👍 Also, when you rebase, template files have been renamed to railties/lib/rails/generators/erb/scaffold/templates/{index, show}.html.erb.tt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its safe to do &.id
instead of .try(:id)
here. Same with the show template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking a little further on this, we could also try to guess a display name property similar to ActiveAdmin but that might result in some overhead.
420715c
to
9386164
Compare
Syntax updated. @gmcgibbon good to go? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will generate something like the following:
<td><%= comment.post&.id %></td>
We don't need to load the associated record to get its ID, we can use the value from the column directly:
<td><%= comment.post_id %></td>
The column_name
method appears to exist for this purpose:
rails/railties/lib/rails/generators/generated_attribute.rb
Lines 119 to 121 in f7fd680
def column_name | |
@column_name ||= reference? ? "#{name}_id" : name | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I guess you can use attribute.column_name
instead of attribute.name
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Much cleaner. Updated, rebased, and pushed.
9386164
to
b54a25b
Compare
@RasPat1 can you clean up the merge conflict on the changelog so we can see about flagging down a maintainer to get this finally merged? |
Also, if you could squash your commits while you're at it that would be 💯 |
Yup, np. |
b54a25b
to
9fa0e89
Compare
railties/CHANGELOG.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ✂️ unnecessary i
at the beginning of the line.
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.
9fa0e89
to
ecb2850
Compare
…-display-memory-address Issue #29200 scaffold an object with a reference displays an object memory address to user
Issue #29200 scaffold an object with a reference displays an object memory address to user rails/rails#29204
Summary
Fix for Issue #29200