Sha256: 83270c432161a26a68a7e3e890ff2707e5ba2574b259d7cfe68016744a2a0eab
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
module Formtastic module Inputs module Base module Associations # :belongs_to, etc def association @association ||= reflection.macro if reflection end def reflection @reflection ||= object.class.reflect_on_association(method) if object.class.respond_to?(:reflect_on_association) end def belongs_to? association == :belongs_to end def association_primary_key if association return reflection.options[:foreign_key] unless reflection.options[:foreign_key].blank? return reflection.foreign_key if reflection.respond_to?(:foreign_key) return :"#{method}_id" if belongs_to? return "#{method.to_s.singularize}_id".pluralize.to_sym else return method.to_s end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nuatt-formtastic-0.2.3 | lib/formtastic/inputs/base/associations.rb |