Skip to content

Commit

Permalink
Ensure attributes with same name as model get scaffolded
Browse files Browse the repository at this point in the history
  • Loading branch information
gazayas authored and jagthedrummer committed Aug 9, 2023
1 parent a66588d commit 3ab6de0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,12 @@ def add_line_to_file(file, content, hook, options = {})
return false
end

if target_file_content.include?(transformed_content)
# When Super Scaffolding strong parameters, if an attribute named :project exists for a model `Project`,
# the `account_load_and_authorize_resource :project,` code prevents the attribute from being scaffolded
# since the transformed content is `:project,`. We bypass that here with this check.
content_matches_model_name = transformed_content.gsub(/[:|,]/, "").capitalize == child

if target_file_content.include?(transformed_content) && !content_matches_model_name
puts "No need to update '#{transformed_file_name}'. It already has '#{transformed_content}'." unless silence_logs?

else
Expand Down

0 comments on commit 3ab6de0

Please sign in to comment.