class String
def foreign_key(separate_class_name_and_id_with_underscore = true)
'Admin::Post'.foreign_key # => "post_id"
'Message'.foreign_key(false) # => "messageid"
'Message'.foreign_key # => "message_id"
the method should put '_' between the name and 'id'.
+separate_class_name_and_id_with_underscore+ sets whether
Creates a foreign key name from a class name.
def foreign_key(separate_class_name_and_id_with_underscore = true) ActiveSupport::Inflector.foreign_key(self, separate_class_name_and_id_with_underscore) end