Method: Mobility::Util#foreign_key

Defined in:
lib/mobility/util.rb

#foreign_key(str) ⇒ String

Creates a foreign key name from a class name

Parameters:

  • str (String)

Returns:

  • (String)


83
84
85
86
87
# File 'lib/mobility/util.rb', line 83

def foreign_key(str)
  call_or_yield str do
    "#{underscore(demodulize(str))}_id"
  end
end