1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #29204 from RasPat1/issue-29200-scaffold-reference-display-memory-address

Issue #29200 scaffold an object with a reference displays an object memory address to user
This commit is contained in:
Ryuta Kamizono 2018-10-16 10:27:35 +09:00
commit b0b0cd1fd7
4 changed files with 21 additions and 5 deletions

View file

@ -1,3 +1,9 @@
* Use Ids instead of memory addresses when displaying references in scaffold views.
Fixes #29200.
*Rasesh Patel*
* Adds support for multiple databases to `rails db:migrate:status`.
Subtasks are also added to get the status of individual databases (eg. `rails db:migrate:status:animals`).

View file

@ -16,7 +16,7 @@
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
<tr>
<% attributes.reject(&:password_digest?).each do |attribute| -%>
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
<td><%%= <%= singular_table_name %>.<%= attribute.column_name %> %></td>
<% end -%>
<td><%%= link_to 'Show', <%= model_resource_name %> %></td>
<td><%%= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>) %></td>

View file

@ -3,7 +3,7 @@
<% attributes.reject(&:password_digest?).each do |attribute| -%>
<p>
<strong><%= attribute.human_name %>:</strong>
<%%= @<%= singular_table_name %>.<%= attribute.name %> %>
<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>
</p>
<% end -%>

View file

@ -435,8 +435,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
end
end
def test_scaffold_generator_belongs_to
run_generator ["account", "name", "currency:belongs_to"]
def test_scaffold_generator_belongs_to_and_references
run_generator ["account", "name", "currency:belongs_to", "user:references"]
assert_file "app/models/account.rb", /belongs_to :currency/
@ -449,7 +449,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_file "app/controllers/accounts_controller.rb" do |content|
assert_instance_method :account_params, content do |m|
assert_match(/permit\(:name, :currency_id\)/, m)
assert_match(/permit\(:name, :currency_id, :user_id\)/, m)
end
end
@ -457,6 +457,16 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_match(/^\W{4}<%= form\.text_field :name %>/, content)
assert_match(/^\W{4}<%= form\.text_field :currency_id %>/, content)
end
assert_file "app/views/accounts/index.html.erb" do |content|
assert_match(/^\W{8}<td><%= account\.name %><\/td>/, content)
assert_match(/^\W{8}<td><%= account\.user_id %><\/td>/, content)
end
assert_file "app/views/accounts/show.html.erb" do |content|
assert_match(/^\W{2}<%= @account\.name %>/, content)
assert_match(/^\W{2}<%= @account\.user_id %>/, content)
end
end
def test_scaffold_generator_database