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:
commit
ade4e7a907
3 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue