lib/rails/generators/generated_attribute.rb in railties-6.0.6.1 vs lib/rails/generators/generated_attribute.rb in railties-6.1.0.rc1

- old
+ new

@@ -1,9 +1,8 @@ # frozen_string_literal: true require "active_support/time" -require "active_support/deprecation" module Rails module Generators class GeneratedAttribute # :nodoc: INDEX_OPTIONS = %w(index uniq) @@ -50,15 +49,10 @@ when /(references|belongs_to)\{(.+)\}/ type = $1 provided_options = $2.split(/[,.-]/) options = Hash[provided_options.map { |opt| [opt.to_sym, true] }] - if options[:required] - ActiveSupport::Deprecation.warn("Passing {required} option has no effect on the model generator. It will be removed in Rails 6.1.\n") - options.delete(:required) - end - return type, options else return type, {} end end @@ -105,15 +99,15 @@ "" end end def plural_name - name.sub(/_id$/, "").pluralize + name.delete_suffix("_id").pluralize end def singular_name - name.sub(/_id$/, "").singularize + name.delete_suffix("_id").singularize end def human_name name.humanize end @@ -129,10 +123,10 @@ def column_name @column_name ||= reference? ? "#{name}_id" : name end def foreign_key? - !!(name =~ /_id$/) + name.end_with?("_id") end def reference? self.class.reference?(type) end