Method: Inflections.foreign_key
- Defined in:
- lib/build/ExtendedString.rb
.foreign_key(class_name, separate_class_name_and_id_with_underscore = true) ⇒ Object
Creates a foreign key name from a class name. separate_class_name_and_id_with_underscore sets whether the method should put ‘_’ between the name and ‘id’.
347 348 349 |
# File 'lib/build/ExtendedString.rb', line 347 def foreign_key(class_name, separate_class_name_and_id_with_underscore = true) underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id") end |