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

Merge pull request #43365 from alpaca-tc/fixed_scaffold

Fixed bug that occurred when scaffold generated a model with nested namespace.
This commit is contained in:
Rafael Mendonça França 2021-11-22 13:23:55 -05:00 committed by GitHub
commit ade4e7a907
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View file

@ -22,7 +22,7 @@ module Erb # :nodoc:
end
end
template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_table_name}.html.erb")
template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_name}.html.erb")
end
private

View file

@ -1,20 +1,20 @@
<div id="<%%= dom_id <%= singular_table_name %> %>">
<div id="<%%= dom_id <%= singular_name %> %>">
<% attributes.reject(&:password_digest?).each do |attribute| -%>
<p>
<strong><%= attribute.human_name %>:</strong>
<% if attribute.attachment? -%>
<%%= link_to <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %>
<%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached? %>
<% elsif attribute.attachments? -%>
<%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
<%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
<%% end %>
<% else -%>
<%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
<%%= <%= singular_name %>.<%= attribute.column_name %> %>
<% end -%>
</p>
<% end -%>
<p>
<%%= link_to "Show this <%= human_name.downcase %>", <%= singular_table_name %> %>
<%%= link_to "Show this <%= human_name.downcase %>", <%= singular_name %> %>
</p>
</div>

View file

@ -273,6 +273,12 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_match(%("New role", new_admin_role_path), content)
end
assert_file "app/views/admin/roles/_role.html.erb" do |content|
assert_match(%("Show this role", role), content)
assert_match "role", content
assert_no_match "admin_role", content
end
%w(edit new show _form).each do |view|
assert_file "app/views/admin/roles/#{view}.html.erb"
end